Skip to content

fix(fuzzylist): reset list cursor on query change#32

Open
rodolfoinfantini wants to merge 1 commit into
cloudmanic:mainfrom
rodolfoinfantini:main
Open

fix(fuzzylist): reset list cursor on query change#32
rodolfoinfantini wants to merge 1 commit into
cloudmanic:mainfrom
rodolfoinfantini:main

Conversation

@rodolfoinfantini

Copy link
Copy Markdown

Summary

This PR resolves an issue in the fuzzy list selection where typing a query would cause the second matching item in the list to be highlighted instead of the first one.

The Problem

When opening the fuzzy finder project selection:

  1. If the list has a group heading at the top (which is non-selectable, e.g. at index 0), the list cursor initially clamps to the first selectable row (at index 1).
  2. When the user starts typing a query, all non-selectable group headings are excluded from the results list, leaving only selectable matching projects (meaning the top matched item is now at index 0 of the filtered list).
  3. However, since the cursor index (l.cursor) remained at index 1, the second matching item was selected instead of the top-ranked match.

The Solution

  • Added tracking for the last active search query (lastQuery) in fuzzyList.
  • In filter(), if the query has changed, the cursor (l.cursor) is reset back to 0 so that the first matched item is highlighted.
  • Added a comprehensive unit test TestFuzzyListQueryChangeResetsCursor in fuzzylist_test.go to verify this behavior and protect against future regressions.

Closes #30

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.

fuzzy finder keeping the second one selected

1 participant