fix code lenses not updating after Undo #2139
Merged
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.
Updating of code lenses should IMO not be tied to selection update as document can get modified programmatically in which case selection might not change.
There is also another weird case where I've noticed this issue during "Undo" and that one has deeper roots... When undoing removal of a line,
on_text_changed_async
is quickly called twice and on the first call selection isdifferent
from the stored one but on the second call, it's not. That results in_when_selection_remains_stable_async
not being triggered (first time because region no longer matches indebounced
and second time becausedifferent
isFalse
so we return early fromon_text_changed_async
). This is an issue that should still be fixed but it's fairly minor and probably doesn't even effect_do_highlights_async
much.That said, switching to
Debouncer
class avoids the above issue affecting code lenses.(I guess we might be a bit concerned about using locks in more places but I think and hope that it's not really that expensive. Especially as
Debouncer
is only holding the lock to update a single property.)Fixes #2136