fix(tui): re-query autocomplete picker on cursor movement#5499
Merged
badlogic merged 1 commit intoJun 8, 2026
Merged
Conversation
moveCursor() repositioned the cursor but never called updateAutocomplete() or cancelAutocomplete(), unlike insertCharacter()/handleBackspace(). So an open autocomplete picker went stale when the cursor moved: e.g. typing `/cmd ` (argument menu open) then arrowing Left back into the command name left the argument list showing against a `/cmd` prefix, and a Tab there concatenated the stale suggestion onto the partial command name (e.g. `/swarepo`). Sync the picker at the end of moveCursor(): when a picker is open, re-query via updateAutocomplete(), which refreshes the list for the new cursor position or closes it when nothing matches. Adds a regression test in test/editor.test.ts (verified to fail without the fix). Fixes earendil-works#5496.
Contributor
|
This PR was auto-closed. Only contributors approved with Maintainers review auto-closed issues daily. Issues that do not meet the quality bar in CONTRIBUTING.md will not be reopened or receive a reply. If a maintainer replies See CONTRIBUTING.md. |
Collaborator
|
Cheers! |
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.
Fixes #5496.
Problem
Editor.moveCursor()repositions the cursor but never callsupdateAutocomplete()orcancelAutocomplete()— unlikeinsertCharacter()andhandleBackspace(), which both keep the picker in sync. So an open autocomplete picker goes stale when the cursor moves.Repro (with a slash command whose first argument is a sub-command, e.g.
repo | message | help):/cmd(trailing space) → the argument picker opens./cmd.applyCompletion's file-path branch (no space before the cursor) and concatenates the stale value onto the partial command name, e.g./cmd+repo→/cmdrepo.Fix
At the end of
moveCursor(), when a picker is open, callupdateAutocomplete()— which re-queries for the new cursor position (refreshing the list, or closing it viarunAutocompleteRequestwhen nothing matches). This mirrors the existinginsertCharacter()/handleBackspace()behaviour.moveCursor()is only reached from the arrow-key dispatch sites, so the refresh does not fire during delete operations.Test
Adds a regression test in
packages/tui/test/editor.test.ts(re-queries the autocomplete picker when the cursor moves back into the command name): types/cmd, arrows Left, and asserts the stale argument items are gone from the rendered picker. Verified it fails without the fix and passes with it. Fullnode --test test/*.test.tsis green (642 tests).Scope
This addresses the reported arrow-key path (
moveCursor). As noted in #5496, other cursor-only movements (Home/End, word jumps, page scroll) share the same gap and could be extended the same way — kept out of this PR to stay focused, happy to broaden if preferred.