Comments (2)
Case 'insert-front + style'
![image](https://private-user-images.githubusercontent.com/31478163/303220868-81449755-a979-448b-bb14-bc3170311cde.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyODQ5MjYsIm5iZiI6MTcyNTI4NDYyNiwicGF0aCI6Ii8zMTQ3ODE2My8zMDMyMjA4NjgtODE0NDk3NTUtYTk3OS00NDhiLWJiMTQtYmMzMTcwMzExY2RlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAyVDEzNDM0NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTFmMTc1NzkzYTVhZGQ3ODZlYzI4N2EwYTAxMzY2YTA2OTkxNTJjY2Q5ZGRmNTg0ZjA2MzQ1NTMxZTA1MDI3ZDQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Z9V1E1bvO6Z8iD09CiAr91l7_KLSwQE0nOQwqoqnkJA)
Description
During concurrent editing and styling of a document, there is an issue where the style attribute is applied to newly inserted nodes. This behavior is unexpected and incorrect.
Steps to Reproduce
- Set the initial state of the document as follows:
0 1 2 3 4 5 6 7 8 9
<root> <p color="red"> a </p> <p color="red"> b </p> <p color="red"> c </p> </root>
<root>
<p color="red">a</p>
<p color="red">b</p>
<p color="red">c</p>
</root>
- Perform the following changes concurrently:
- Client1's local change: Edit(Insert)
<p italic="true">d</p>
at [3, 3] - Client2's local change: Style attribute
"bold"="aa"
at [3, 6]
- Client1's local change: Edit(Insert)
- Sync Client1 and Client2
Current Result
The results after applying and syncing local changes to each client are as follows:
Client1:
- After Edit(local change)
<root>
<p color="red">a</p>
<p italic="true">d</p>
<p color="red">b</p>
<p color="red">c</p>
</root>
- Edit after Style(sync)
<root>
<p color="red">a</p>
<p "bold"="aa" italic="true">d</p>
<p "bold"="aa" color="red">b</p>
<p color="red">c</p>
</root>
Client2:
- After Style(local change)
<root>
<p color="red">a</p>
<p "bold"="aa" color="red">b</p>
<p color="red">c</p>
</root>
- Style after Edit(sync)
<root>
<p color="red">a</p>
<p italic="true">d</p>
<p "bold"="aa" color="red">b</p>
<p color="red">c</p>
</root>
Suggestion
1. Lamport clock comparison
It is important to differentiate between nodes that have been newly inserted and existing nodes during the concurrent editing and styling process. This distinction will help in precisely applying style operations within the appropriate scope.
By applying the rules below, all failure cases for style-related tests that occurred in the previously written tree-concurrency-test can be resolved.
- Before
yorkie/pkg/document/crdt/tree.go
Lines 859 to 871 in a8f6bc2
- After
err = t.traverseInPosRange(fromParent, fromLeft, toParent, toLeft,
func(token index.TreeToken[*TreeNode], _ bool) {
node := token.Node
if !node.IsRemoved() && !node.IsText() && len(attributes) > 0 {
if editedAt.After(node.ID.CreatedAt) {
return
}
// ...
}
})
Since the priority of the Lamport timestamp does not guarantee concurrent causality, this method does not solve the problem.
from yorkie.
- Go SDK: #854
- JS SDK: yorkie-team/yorkie-js-sdk#803
- Android SDK: yorkie-team/yorkie-android-sdk#178
- iOS SDK: yorkie-team/yorkie-ios-sdk#166
from yorkie.
Related Issues (20)
- Improve performance of Splay Tree in crdt.Text data structure to prevent skewness HOT 8
- Error occurs when executing `FindDocInfosByKeys` query with empty docKeys argument HOT 1
- Server panics due to convert unhashable struct to connnect.Error HOT 2
- Consider Cascade Delete on Admin Deletion HOT 2
- Cache Changes to Improve Overall PushPull/MongoDB Performance HOT 2
- CI workflow doesn't work due to Docker Compose V1 being deprecated on the runner's ubuntu image HOT 8
- Fine-tune CI Workflows in PR HOT 4
- Provide global output flag for setting output format in CLI commands
- Suggest conducting research on Loro and the operating principles of Loro's DiffCalculator.
- Set updatedAt value for newly created documents HOT 2
- Add Team and Member Management Features
- Move from server configuration to project-level settrings
- Versioned Document Schema & Validation
- Add `include_presences` to return active user list in `GetDocument`, `GetDocuments`
- Optimize `crdt.Array` Data Structure for Improved Performance
- Add Account Deletion and Password Change to CLI Commands HOT 1
- Add metrics related to watch stream HOT 1
- Implement CRDT Move Convergence Mechanism
- Roadmap for Array
- Fix Lint Errors Related to golangci-lint v1.60.3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yorkie.