Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect calculation in indexTree.treePosToPath operation #751

Merged
merged 5 commits into from
Feb 21, 2024

Conversation

raararaara
Copy link
Contributor

@raararaara raararaara commented Feb 20, 2024

What this PR does / why we need it?

This patch addresses an issue arising from the tree.edit operation in response to problem with calculating the fromPath when multiple treePos represent a single index-based coordinate, leading to inaccuracies.

Any background context you want to provide?

In some cases, a single index-based coordinate can be represented by multiple treePos, causing complications in extracting the path. To resolve this, logic has been implemented in treePosToPath to handle cases where children consist only of text type.

image

Case description: In a situation where the children of <node> consist only of text type nodes, and the "e" text Node has already been removed, an additional operation is made to remove the text "f".

  • AS-IS: When finding treePos, if leftNode was removed, {parentNode, offset from children} was searched.(return [1, 0, 0, 4] for above case)
  • TO-BE: If the node's children consist of only text type nodes, the offset must be set based on text.(should be [1, 0, 0, 7]

What are the relevant tickets?

Address #749

Checklist

  • Added relevant tests or not required
  • Didn't break anything

@raararaara raararaara added bug 🐞 Something isn't working sdk ⚒️ labels Feb 20, 2024
Copy link

codecov bot commented Feb 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (16bbe87) 81.35% compared to head (a600dda) 81.50%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #751      +/-   ##
==========================================
+ Coverage   81.35%   81.50%   +0.15%     
==========================================
  Files          59       59              
  Lines        4344     4348       +4     
  Branches      852      853       +1     
==========================================
+ Hits         3534     3544      +10     
+ Misses        547      543       -4     
+ Partials      263      261       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@raararaara raararaara changed the title Fix incorrect path returned when using treePosToPath in case of text children only Fix incorrect calculation in tree.edit operation in response to issue Feb 20, 2024
@raararaara raararaara changed the title Fix incorrect calculation in tree.edit operation in response to issue Fix incorrect calculation in tree.edit operation Feb 20, 2024
@raararaara raararaara changed the title Fix incorrect calculation in tree.edit operation Fix incorrect calculation in indexTree.treePosToPath operation Feb 20, 2024
@hackerwins hackerwins marked this pull request as ready for review February 20, 2024 08:56
Copy link
Contributor

@chacha912 chacha912 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

test/integration/tree_test.ts Outdated Show resolved Hide resolved
src/util/index_tree.ts Outdated Show resolved Hide resolved
Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution.

@hackerwins hackerwins merged commit 5c8e56f into main Feb 21, 2024
2 checks passed
@hackerwins hackerwins deleted the fix-incorrect-tree-path branch February 21, 2024 06:56
hackerwins added a commit to yorkie-team/yorkie that referenced this pull request Mar 20, 2024
This commit addresses an issue arising from the tree.edit operation in
response to problem with calculating the fromPath when multiple
treePos represent a single index-based coordinate, leading to
inaccuracies.

This commit contains migration work for yorkie-team/yorkie-js-sdk#751,
so detailed information can also be found there.

---------

Co-authored-by: Youngteac Hong <susukang98@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working sdk ⚒️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants