-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Defer bracket pair document parsing until it's actually used #163958
Conversation
@alexdima can I not use set/clearImmediate in monaco?
|
Unfortunately |
@alexdima good to know, will switch to timeout |
src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/bracketPairsTree.ts
Outdated
Show resolved
Hide resolved
Adding @rebornix so I can get this in before endgame |
@alexdima oh auto merge was enabled while I was typing. My thinking was he was already keen on the idea, just that it caused issues with the timeout. So merging now would make it in for testing and he could comment/revert if there is a problem with it. |
I pinged @hediet about it to make sure he checks it out |
The incremental bracket pair parser expects that the given edits precisely describe the changes between the state of the text model it saw the last time and the current state of the text model. Imagine you start with this document:
Now the user
This translates to these edits:
The state after (1) is:
The state after (2) is:
The state after (3) is:
However, when the parser processes (1), it already sees the state (3). What would work though is to combine the changes, as we discussed some time ago (for precisely this problem). In that case, you would only issue this edit:
This would not only be correct, but also more performant, as the parser only needs to do one pass. However, combining changes is not entirely trivial: You have to describe later changes in terms of the initial situation. This should be doable in linear time though. |
Revert "Merge pull request #163958 from microsoft/tyriar/161622_brack…
…ket_queue Defer bracket pair document parsing until it's actually used
Revert "Merge pull request microsoft#163958 from microsoft/tyriar/161622_brack…
Part of #161622
This change queues parsing of the document so that it does not block editor input latency. This is done via
setImmediate
such that it is called before any timers, the only downside to this is that changing a character adjacent to a bracket may appear white for a single frame.This is a good trade off imo to save what I measured sometimes to be > 10% of the keypress event's runtime. The amount of time spent is quite variable, not sure why.