-
Notifications
You must be signed in to change notification settings - Fork 135
feat: add interactive picker #468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Since |
| layout_span(layout, (state.prompt_text.as_ref().into(), prompt_style)); | ||
| layout_span(layout, (" › ".into(), Style::new().cyan().dim())); | ||
| layout_span(layout, (state.input_state.value().into(), Style::new())); | ||
| layout_span(layout, (CARET.into(), Style::new())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to change the caret shape to indicate that it is in input mode.
305af73 to
f0d61e0
Compare
1cb919e to
cc0754c
Compare
Testing NoteThis PR adds the picker component itself, but it's not integrated into any operations yet. To test the picker functionality in action, please check out #470 which converts branch operations to use this picker: gh pr checkout 470
cargo runThen try branch operations like:
You'll be able to see the fuzzy filtering, navigation, and selection in action. |
Implement an interactive fuzzy finder picker component: - Fuzzy matching with real-time filtering - Keyboard navigation (↓/↑, Ctrl-n/p) - Select with Enter, cancel with Esc/Ctrl-c - Visual highlighting of matched characters Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
cc0754c to
948ad2d
Compare
|
I just wanted to leave some answer at least. I'm a bit busy with other things, but I think this (and the search functionality too) are nice additions to Gitu. I'll try find some time to review and test this properly soon |
|
Like |
- Add picker UI layout tests with snapshots - Remove duplicate picker tests from src/tests/picker.rs - Consolidate case-insensitive test into src/picker.rs - Clean up 39 unreferenced snapshot files
Add tests covering generic picker functionality needed for branch selection and similar use cases: Logic tests (src/picker.rs): - Scrolling through many items (20+) - Navigation after filtering - Custom input selection with state transitions - Navigation with custom input at end of list UI tests (src/ui/picker.rs): - Scroll display at middle position - Scroll display near end - No matches display - Filtered results with navigation All tests are organized by category (basic → edge cases) and placed next to related tests for better maintainability.
Done. |
README.md
Outdated
| > [!NOTE] | ||
| > Picker keybinds will be configurable in a future release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well do this right away. shouldn't be too much extra
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Do you think a tab/shift-tab keybinding would be a nice default in addition to ctrl-n. ctrl-p? |
Add support for customizing picker keybindings through the config file. Users can now configure next, previous, done, and cancel actions under [bindings.picker] section in their config.toml.
I think that's a good idea. Especially for users familiar with Magit, many are likely accustomed to using Tab/Shift-Tab for navigation. |
…picker # Conflicts: # Cargo.toml # src/tests/snapshots/gitu__tests__non_utf8_diff.snap
| base_style: Style, | ||
| config: &Config, | ||
| ) { | ||
| let graphemes: Vec<&str> = text.graphemes(true).collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need to collect this before iterating, saves an allocation!
| selection_line = { mods = "BOLD" } # Selected item style | ||
| matched = { fg = "yellow", mods = "BOLD" } # Fuzzy-matched characters highlight | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this doesn't belong in the README, it's a bit too specific. There's documentation about configuration inside of default_config.toml.
Having the code comments inside of default_config.toml seems like the better approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover?
| } | ||
| } | ||
|
|
||
| pub struct PickerBindings { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize this was indeed not as smooth to add, due to how the existing bindings always relate to a menu.
Could clean it up in the future, think this is good enough for now!
| picker.next = ["down", "ctrl+n"] | ||
| picker.previous = ["up", "ctrl+p"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the tab bindings would be like this.
| picker.next = ["down", "ctrl+n"] | |
| picker.previous = ["up", "ctrl+p"] | |
| picker.next = ["down", "ctrl+n", "tab"] | |
| picker.previous = ["up", "ctrl+p", "shift+tab"] |
altsem
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'll just merge this to master. And make the small adjustments i commented on. I think it looks pretty good!
I suppose in the other PR, things will get more interesting when it is actually put to use!
Summary
This PR adds an interactive fuzzy finder picker component for branch and commit selection:
Implementation Details
pickermodule with fuzzy matching logicui/pickerfor rendering the picker interfaceTest Plan
🤖 Generated with Claude Code