-
Notifications
You must be signed in to change notification settings - Fork 16
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
GhostCells: Fix removal of ghost rendering and prevent stale inserts #1554
Conversation
Need to merge #1536 first and then rebase. |
@sourishkrout This is ready for review. The caveat is the unittest is failing because of a problem with mocking out the An alternative solution is I can refactor the code to define it as an instance variable on the GhostCell Generator class. |
👍 will take a look.
I'll figure out a fix. I'm sure there's a way without requiring a refactor. |
Thank you! |
This should fix the mock, @jlewi. I haven't reviewed the rest of the PR yet. Will do that tmrw.
|
Quality Gate passedIssues Measures |
That did it thank you very much. |
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.
✅ LGTM and works locally.
This PR fixes two issues with ghost cells.
Preventing stale inserts
The server can return a completion after the editor has changed invalidating the completion. For example, prior to this PR we observe the following
This is not what should happen. As soon as the focus switches away from cell N any completions based on cell N should be invalidated and ignored.
To deal with that we introduce a context id. This is just a ULID that gets changed whenever something changes warranting a new stream of completions. The context id changes whenever the user changes the focus in the notebook. The context id gets set on the completions sent to the foyle and is returned in the completion responses.
The frontend can then check whether the context id in the response matches the current context; if it doesn't then the completion is ignored.
Ghost Decorations weren't being removed
The ghost decorations weren't being removed when a cell was being accepted. The problem is that to remove the textdecorations we need to pass a reference to the decoration to be removed to the setDecoration function. I however was using the function getGhostDecoration to create a new instance of the decoration so it wasn't getting removed.