feat(filepicker): add search/filter functionality#994
Open
toller892 wants to merge 1 commit into
Open
Conversation
Add incremental search to the file picker component, allowing users to filter visible files by name. Press '/' to enter search mode, type to filter, Enter to confirm, Esc to cancel. Changes: - Add '/' key binding to enter search mode with a text input - Filter displayed files using case-insensitive substring matching - Show search bar while typing, filter status bar when confirmed - Navigation keys (j/k/g/G/pgup/pgdown) work on filtered list - Esc clears filter first, then navigates to parent directory - Entering a directory clears the active search - Add FilterFunc type and DefaultFilter for customizable filtering - Add Filter field to Model for user-supplied filter functions Fixes charmbracelet/bubbletea#1685
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
Adds incremental search to the file picker component, allowing users to filter visible files by name within the current directory.
Motivation
Finding a specific file in a large directory is tedious — you have to scroll through everything. This adds vim-style
/search to filter files in place. (bubbletea#1685)Usage
/EnterEsc(in search)Esc(browsing)All navigation keys (
j/k/g/G/PgUp/PgDn) work on the filtered list. Entering a directory clears the search.Implementation
FilterFunctype +DefaultFilter(case-insensitive substring) for customizable filteringFilterfield onModel— users can swap in fuzzy matching (sahilm/fuzzy) or any custom logictextinput.Model(same pattern aslistcomponent's filter)filteredFiles/filteredMaptrack the mapping between filtered and original indicesBackclears the search automaticallyTesting
All pass. The filepicker has no existing test file; I can add tests if desired.