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

Fix: transform error for path
This commit is contained in:
Vincent Chan 2022-07-27 19:58:59 +08:00 committed by GitHub
commit ddb2cb7d66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

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

View File

@ -19,6 +19,7 @@ void main() {
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, 1]), [0, 1]);
expect(transformPath([1, 1], [1, 0]), [1, 0]);
});
test("transform path delta", () {
expect(transformPath([0, 1], [0, 1], 5), [0, 6]);