-
Notifications
You must be signed in to change notification settings - Fork 18
feat: use Ctrl-N/Ctrl-P for vertical movement in lists #197
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // Ctrl-N/Ctrl-P are the readline/emacs bindings for next/previous line | ||
| pub(crate) const CTRL_N: char = '\u{e}'; | ||
| pub(crate) const CTRL_P: char = '\u{10}'; | ||
|
|
||
| pub(crate) const CTRL_U: char = '\u{15}'; | ||
| pub(crate) const CTRL_W: char = '\u{17}'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ mod dialog; | |
| mod event; | ||
| mod height; | ||
| mod input; | ||
| mod keys; | ||
| mod list; | ||
| mod multiselect; | ||
| mod option; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ use fuzzy_matcher::skim::SkimMatcherV2; | |
| use itertools::Itertools; | ||
| use termcolor::{Buffer, WriteColor}; | ||
|
|
||
| use crate::keys::{CTRL_N, CTRL_P}; | ||
| use crate::theme::Theme; | ||
| use crate::{DemandOption, ctrlc, theme}; | ||
|
|
||
|
|
@@ -199,8 +200,8 @@ impl<'a, T> MultiSelect<'a, T> { | |
| }; | ||
| if self.filtering { | ||
| match key { | ||
| Key::ArrowDown => self.handle_down()?, | ||
| Key::ArrowUp => self.handle_up()?, | ||
| Key::ArrowDown | Key::Char(CTRL_N) => self.handle_down()?, | ||
| Key::ArrowUp | Key::Char(CTRL_P) => self.handle_up()?, | ||
|
Comment on lines
+203
to
+204
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Advertise the new navigation keys in the help text.
Also applies to: 222-223 🤖 Prompt for AI Agents🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Preserve custom Ctrl-N/Ctrl-P toggle bindings. These navigation arms now match before Also applies to: 222-223 🤖 Prompt for AI Agents |
||
| Key::ArrowLeft => self.handle_left()?, | ||
| Key::ArrowRight => self.handle_right()?, | ||
| Key::Enter => { | ||
|
|
@@ -212,14 +213,14 @@ impl<'a, T> MultiSelect<'a, T> { | |
| Key::Escape => self.handle_stop_filtering(false)?, | ||
| Key::Backspace => self.handle_filter_backspace()?, | ||
| key if key == self.toggle_key => self.handle_toggle(), | ||
| Key::Char(c) => self.handle_filter_key(c)?, | ||
| Key::Char(c) if !c.is_control() => self.handle_filter_key(c)?, | ||
| _ => {} | ||
| } | ||
| } else { | ||
| self.term.hide_cursor()?; | ||
| match key { | ||
| Key::ArrowDown | Key::Char('j') => self.handle_down()?, | ||
| Key::ArrowUp | Key::Char('k') => self.handle_up()?, | ||
| Key::ArrowDown | Key::Char('j') | Key::Char(CTRL_N) => self.handle_down()?, | ||
| Key::ArrowUp | Key::Char('k') | Key::Char(CTRL_P) => self.handle_up()?, | ||
| Key::ArrowLeft | Key::Char('h') => self.handle_left()?, | ||
| Key::ArrowRight | Key::Char('l') => self.handle_right()?, | ||
| key if key == self.toggle_key || key == Key::Char('x') => self.handle_toggle(), | ||
|
|
||
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Keep user-facing navigation help synchronized with the new bindings.
Each handler now supports Ctrl-N/Ctrl-P, but its corresponding help text still lists only arrows and
j/k.src/list.rs#L165-L166: update the help text near Line 330.src/multiselect.rs#L222-L223: update the help text near Line 610.src/select.rs#L192-L193: update the help text near Line 453.📍 Affects 3 files
src/list.rs#L165-L166(this comment)src/multiselect.rs#L222-L223src/select.rs#L192-L193🤖 Prompt for AI Agents