Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Persist a subset of IdMap #10347
Persist a subset of IdMap #10347
Changes from 4 commits
4bd7eb7
86542fe
3e124c0
21fd249
9e864b6
a7d81fe
d276905
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition is no longer accurate: A new
idMapToPersist
needs to be computed if the ID map changes or if the metadata changes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the metadata line changes, the IdMap will be recomputed as well. And if the metadata was changed without changing the IDs, we don't need to edit the IdMap section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this being enforced in the ydoc-server. If you mean it will be recomputed at the same time in the GUI, the ydoc-server should not depend on that.
When adding a new node, first the new node is committed then its position is computed. In the interim, the node usually doesn't have any non-default metadata; if we are always writing node metadata at the same time that a node is added, that's an inefficiency we should be able to fix in the GUI without the ydoc-server causing data loss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed a problem. There needs to be a check if
newMetadata
contains a new key. At the minimum, This could be(newIdMap || newMetadata) &&
, effectively always writing ID Map when any metadata changes. That could be further optimized later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see that
applyDocumentUpdates
enso/app/gui2/ydoc-server/languageServerSession.ts
Lines 451 to 455 in 305f69c
recomputes IdMap from the
root
ASTenso/app/gui2/ydoc-server/edits.ts
Lines 67 to 74 in 305f69c
or am I reading that wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition
codeChanged || idsChanged || synced.idMapJson == null
can still be false when existing metadata structure updates. In that situation a new ID will have to be stored while no code was actually changed.Currently, all metadata is written on expressions that also happen to be node roots, so it kinda works out. But this is not a limitation of the system that we are willing to have, since we are soon going to add metadata to individual expressions. That will be needed to store persistent widget state. Those expressions will already exist when we adjust the widget data, effectively sending a delaying metadata update without any code changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated