Skip to content
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

fix code lenses not updating after Undo #2139

Merged
merged 6 commits into from
Dec 18, 2022
Merged

fix code lenses not updating after Undo #2139

merged 6 commits into from
Dec 18, 2022

Conversation

rchl
Copy link
Member

@rchl rchl commented Dec 13, 2022

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 is different 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 in debounced and second time because different is False so we return early from on_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

@rchl
Copy link
Member Author

rchl commented Dec 13, 2022

Note on Debouncer and locks. I guess we could create a non-thread-safe variant of it that would not use locks but then it would be our responsibility to ensure that .debounce() is only called on the same thread as the function it runs.

@rchl
Copy link
Member Author

rchl commented Dec 14, 2022

Changed Debouncer to be not thread-safe as we don't currently seem to have a need for thread safe version.

@rchl
Copy link
Member Author

rchl commented Dec 18, 2022

No complains I guess. :)

@rchl rchl changed the title fix code lenses not updating after doing Undo fix code lenses not updating after Undo Dec 18, 2022
@rchl rchl merged commit 2e2b3d4 into main Dec 18, 2022
@rchl rchl deleted the fix/code-lenses-refresh branch December 18, 2022 21:18
rchl added a commit that referenced this pull request Jan 16, 2023
* main: (30 commits)
  Make Document Symbols behavior more consistent with built-in Goto Symbol (#2166)
  docs: fsautocomplete config - remove redundant argument (#2165)
  Allow missing window/workDoneProgress/create request from the server (#2159)
  Use "plaintext" language ID for plain text files (#2164)
  Improve type annotations (#2162)
  Don't use "escapeall" extension when formatting with mdpopups (#2163)
  Cut 1.21.0
  Fix inlay hint parts wrapping into multiple lines (#2153)
  Ensure commands triggered from minihtml run on correct view (#2154)
  Add "Source Action" entry to the "Edit" main menu (#2149)
  Add "Refactor" entry to the "Edit" main menu (#2141)
  fix completion documentation being parsed as markdown twice (#2146)
  when going to definition scroll to start of the region, not end (#2147)
  Auto-restart on server crashing, up to 5 times (#2145)
  improve performance of completion & signature request on typing (#2148)
  fix code lenses not updating after Undo (#2139)
  docs: fix mixed indentation in language servers configuration
  add missing Goto commands to Command Palette (#2140)
  docs: add missing keyboard shortcuts (#2143)
  Pass force_group to LocationPicker (#2134)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code Lenses fail to update their position (and content) after Undo
1 participant