Selaa lähdekoodia

Merge pull request #728 from AppFlowy-IO/fix/transform-operation

Fix: transform error for path
Vincent Chan 2 vuotta sitten
vanhempi
commit
ddb2cb7d66

+ 2 - 0
frontend/app_flowy/packages/flowy_editor/lib/operation/operation.dart

@@ -128,6 +128,8 @@ Path transformPath(Path preInsertPath, Path b, [int delta = 1]) {
   final bAtIndex = b[preInsertPath.length - 1];
   final bAtIndex = b[preInsertPath.length - 1];
   if (preInsertLast <= bAtIndex) {
   if (preInsertLast <= bAtIndex) {
     prefix.add(bAtIndex + delta);
     prefix.add(bAtIndex + delta);
+  } else {
+    prefix.add(bAtIndex);
   }
   }
   prefix.addAll(suffix);
   prefix.addAll(suffix);
   return prefix;
   return prefix;

+ 1 - 0
frontend/app_flowy/packages/flowy_editor/test/operation_test.dart

@@ -19,6 +19,7 @@ void main() {
     test("transform path not changed", () {
     test("transform path not changed", () {
       expect(transformPath([0, 1, 2], [0, 0, 7, 8, 9]), [0, 0, 7, 8, 9]);
       expect(transformPath([0, 1, 2], [0, 0, 7, 8, 9]), [0, 0, 7, 8, 9]);
       expect(transformPath([0, 1, 2], [0, 1]), [0, 1]);
       expect(transformPath([0, 1, 2], [0, 1]), [0, 1]);
+      expect(transformPath([1, 1], [1, 0]), [1, 0]);
     });
     });
     test("transform path delta", () {
     test("transform path delta", () {
       expect(transformPath([0, 1], [0, 1], 5), [0, 6]);
       expect(transformPath([0, 1], [0, 1], 5), [0, 6]);