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

Implement Tree.RemoveStyle #748

Merged
merged 12 commits into from
Jan 19, 2024
Merged

Implement Tree.RemoveStyle #748

merged 12 commits into from
Jan 19, 2024

Conversation

justiceHui
Copy link
Member

@justiceHui justiceHui commented Jan 5, 2024

What this PR does / why we need it:

  • Implemented Tree.RemoveStyle.
  • Added test codes to test RHT behavior in a concurrency scenario:
    • Edit style by 2 users (4 * 6 * 6 = 144 cases):
      • Ranges: A = B, A contains B, A and B are intersecting, not intersecting.
      • Operations: RemoveStyle({'bold'}), Style({'bold': 'aa'}), Style({'bold': 'bb'}), RemoveStyle({'italic'}), Style({'italic': 'aa'}), Style({'italic': 'bb'}).
    • Edit tree and Edit style (6 * 5 * 2 = 60 cases):
      • Ranges: A = B, A contains B, B contains A, A and B are intersecting, B is next to A, A is next to B.
      • Operations for A: Insert front of range, Insert back of range, Insert middle of range, Delete, Change.
      • Operations for B: RemoveStyle({'bold'}), Style({'bold': 'aa'}).

Which issue(s) this PR fixes:

Addresses #626

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Additional documentation:


Checklist:

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

@CLAassistant
Copy link

CLAassistant commented Jan 5, 2024

CLA assistant check
All committers have signed the CLA.

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. I left a few comments.

test/integration/tree_test.go Outdated Show resolved Hide resolved
pkg/document/crdt/tree.go Show resolved Hide resolved
pkg/document/json/tree.go Show resolved Hide resolved
Copy link

codecov bot commented Jan 9, 2024

Codecov Report

Attention: 40 lines in your changes are missing coverage. Please review.

Comparison is base (3876b8f) 49.48% compared to head (0741b44) 50.00%.
Report is 4 commits behind head on main.

Files Patch % Lines
pkg/document/crdt/tree.go 0.00% 25 Missing ⚠️
api/converter/from_pb.go 0.00% 9 Missing ⚠️
api/converter/to_pb.go 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #748      +/-   ##
==========================================
+ Coverage   49.48%   50.00%   +0.51%     
==========================================
  Files          69       69              
  Lines       10099    10224     +125     
==========================================
+ Hits         4997     5112     +115     
+ Misses       4587     4570      -17     
- Partials      515      542      +27     

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

@justiceHui justiceHui marked this pull request as ready for review January 10, 2024 01:06
@justiceHui justiceHui changed the title Draft commit for implement Tree.RemoveStyle Implement Tree.RemoveStyle Jan 10, 2024
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.

Thank you for your reflection. 👍

Next, we need to be sure that concurrent adding attributes and removing them is correct by adding test cases.

pkg/document/crdt/tree.go Outdated Show resolved Hide resolved
@justiceHui justiceHui marked this pull request as draft January 10, 2024 07:52
@justiceHui justiceHui marked this pull request as ready for review January 18, 2024 09:55
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 ee9cadb into main Jan 19, 2024
3 checks passed
@hackerwins hackerwins deleted the tree-remove-style branch January 19, 2024 07:07
hackerwins pushed a commit that referenced this pull request Jan 19, 2024
This commit added tests for Tree behavior in concurrency scenarios:

Styles by 2 users (4 * 6 * 6 = 144 cases):
  - Ranges(4)
    - A = B
    - A contains B
    - A and B are intersecting
    - not intersecting
  - Operations for both A and B(6)
    - `RemoveStyle({'bold'})`
    - `Style({'bold': 'aa'})`
    - `Style({'bold': 'bb'})`
    - `RemoveStyle({'italic'})`
    - `Style({'italic': 'aa'})`
    - `Style({'italic': 'bb'})`

Edit and Style (6 * 5 * 2 = 60 cases):
  - Ranges(6)
    - A = B
    - A contains B
    - B contains A
    - A and B are intersecting
    - B is next to A
    - A is next to B.
  - Operations for A(5)
    - Insert front of range
    - Insert back of range
    - Insert middle of range
    - Delete
    - Change
  - Operations for B(2)
    - `RemoveStyle({'bold'})`
    - `Style({'bold': 'aa'})`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants