Repository navigation
fix(ui): keep background fold maintenance out of Normal mode - #568
Merged
Merged
Conversation
state.ui.output_folds authoritative fold ranges
| derive
v
output window folds window-local, rebuilt while user types
|
+-- old: :normal! zE / zd -> global State = Normal
| -> ModeChanged i:n, attributed to output buf
+-- new: foldmethod recompute / rebuild recorded ranges
-> mode untouched
Folds are window-local, mode is global. Deriving folds for a background
window used to emit a mode change to listeners of the input window, which
is where the input source switch hangs. Clearing by foldmethod recompute
and repairing by rebuilding the recorded ranges keeps that derivation
inside the output window.
Cost: O(rendered lines) instead of O(folds); 1.65us per 1000 rendered
lines, unchanged in the default lazy window.
Tests: real-UI mode/key observers and a PTY streaming run wired into CI
assert no ModeChanged, no synthetic Normal keys, and that an intentional
<Esc> is still reported.
Fixes sudo-tee#567
jensenojs
marked this pull request as ready for review
November 16, 2026 12:01
Owner
|
Thanks for the fix This seems like a reasonable approach |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Fixes #567
IME composition and input state get interrupted while typing whenever the output window streams or scrolls.
Neovim has no API to delete manual folds , so async fold rebuilds ran
:normal! zE/zdin the unfocused output window—flipping global mode to Normal mid-typing (noautocmdonly hides the event;vim.on_keystill observesz,Ein Normal):noautocmdhides the autocmd but the mode still changes;vim.on_keyobservesz,Ein Normal during the call.Change
Cost: clearing is O(rendered lines) instead of O(folds) — 1.65 µs per 1000 rendered lines. Not measurable in the default lazy window (0.19 vs 0.21 ms per fold change); fully expanded history at 70k lines is 1.98 vs 0.83 ms.