Skip to content

Fix console completion selection reset when navigating with arrow keys - #99

Merged
ernestrc merged 3 commits into
unstablebuild:mainfrom
Spandan-Mishra:fix/console-completion-arrow-nav
Sep 26, 2026
Merged

ernestrc merged 3 commits into
unstablebuild:mainfrom
Spandan-Mishra:fix/console-completion-arrow-nav

Conversation

@Spandan-Mishra

Copy link
Copy Markdown
Contributor

Summary

Fixes #89.
As per approval by @ernestrc on discord: https://discord.com/channels/1498290662095716374/1549066961932124210/1550224117976924271

When navigating completion candidates in the Rune console (rune>) using the ArrowDown or ArrowUp keys, pressing Enter or Tab erroneously accepted the very first candidate instead of the highlighted candidate.

Root Cause

ideshell.Handler tracks candidate navigation using h.compMoved. When accepting completion via acceptSearch(), if len(h.query) == 0 and !h.compMoved, h.list.FocusStart() is called to reset focus to index 0. While the Ctrl-n/Ctrl-j bindings set h.compMoved = true, the KeyArrowDown and KeyArrowUp branches omitted setting this flag.

Changes

  • In internal/ide/ideshell/handler.go (handleCompletion), set h.compMoved = true under term.KeyArrowUp and term.KeyArrowDown.
  • In internal/ide/ideshell/completion_test.go, added TestCompletion_ArrowKeyNavigationPreservedOnAccept verifying that arrow key navigation is preserved upon accepting with both Enter and Tab.

Results

screenrecording-2026-09-18_17-30-40.mp4

Spandan-Mishra and others added 2 commits September 18, 2026 17:45
In ideshell.Handler, the compMoved boolean tracks whether the user
has navigated away from the initial candidate (index 0) in the
completion overlay. When accepting completion via Enter or Tab,
acceptSearch checks !h.compMoved and resets focus to index 0 via
FocusStart if no query filter characters were typed.

While Ctrl-j/Ctrl-n and Ctrl-k/Ctrl-p set h.compMoved = true, the
term.KeyArrowUp and term.KeyArrowDown event handlers omitted setting
this flag. Navigating candidates using arrow keys followed by Enter or
Tab erroneously reverted the selection to the first candidate.

Set h.compMoved = true when processing term.KeyArrowUp and
term.KeyArrowDown in handleCompletion.

Fixes unstablebuild#89

Signed-off-by: Spandan Mishra <[email protected]>
@ernestrc
ernestrc enabled auto-merge (squash) September 20, 2026 21:16
@ernestrc
ernestrc disabled auto-merge September 20, 2026 21:16
@ernestrc
ernestrc enabled auto-merge (squash) September 20, 2026 21:16
@codecov

codecov Bot commented Sep 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ernestrc
ernestrc merged commit f63c515 into unstablebuild:main Sep 26, 2026
8 checks passed
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

bug: Console completion resets selection to first candidate when navigating with arrow keys

3 participants