fix(nvim): preserve list cursor position on picker resume#613
Open
KorigamiK wants to merge 2 commits into
Open
fix(nvim): preserve list cursor position on picker resume#613KorigamiK wants to merge 2 commits into
KorigamiK wants to merge 2 commits into
Conversation
Resuming a picker wrote the saved query into the input buffer, whose on_lines callback scheduled on_input_change. That re-ran the search and reset the cursor to the first result, discarding the restored position. Suppress that single on_input_change during restore so the snapshot's items and cursor are kept verbatim, rendering once instead of relying on a second scheduled re-assert.
89294c4 to
5a8fa5f
Compare
Resuming a picker reset the selected entry to the first result. The saved cursor was restored, but writing the query into the input buffer triggers on_input_change, which re-runs the search and sets S.cursor = 1. Re-running the search on resume is intentional (results may have changed since close), so instead of suppressing it, thread the saved cursor through: restore_from_state stashes it in pending_restore_cursor and the re-search restores that position, clamped to the fresh result count.
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.
Summary
Fixes #612.
Resuming a picker did not restore the selected list item — the highlight always reset to the first result.
restore_from_staterestoresstate.cursor, then writes the saved query into the input buffer. The buffer'son_linescallback scheduleson_input_change, which re-runs the search and unconditionally doesS.cursor = 1, clobbering the restored cursor.Fix
Suppress that single
on_input_changeduring restore via a one-shotsuppress_input_changeflag. The snapshot already holds the exactitems/filtered_items/cursor, so re-running the search on resume is both unnecessary and the source of the bug. Suppressing it preserves the restored cursor naturally and renders once, instead of relying on a second scheduled re-assert of the cursor.Testing
prompt_positiontopandbottom.