Skip to content
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

support Tab / BackTab to cycle through items #141

Merged
merged 1 commit into from Oct 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/prompts/fuzzy_select.rs
Expand Up @@ -174,7 +174,7 @@ impl FuzzySelect<'_> {
term.show_cursor()?;
return Ok(None);
}
Key::ArrowUp if filtered_list.len() > 0 => {
Key::ArrowUp | Key::BackTab if filtered_list.len() > 0 => {
if sel == !0 {
sel = filtered_list.len() - 1;
} else {
Expand All @@ -183,7 +183,7 @@ impl FuzzySelect<'_> {
}
term.flush()?;
}
Key::ArrowDown if filtered_list.len() > 0 => {
Key::ArrowDown | Key::Tab if filtered_list.len() > 0 => {
if sel == !0 {
sel = 0;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/prompts/multi_select.rs
Expand Up @@ -221,14 +221,14 @@ impl MultiSelect<'_> {
term.flush()?;

match term.read_key()? {
Key::ArrowDown | Key::Char('j') => {
Key::ArrowDown | Key::Tab | Key::Char('j') => {
if sel == !0 {
sel = 0;
} else {
sel = (sel as u64 + 1).rem(self.items.len() as u64) as usize;
}
}
Key::ArrowUp | Key::Char('k') => {
Key::ArrowUp | Key::BackTab | Key::Char('k') => {
if sel == !0 {
sel = self.items.len() - 1;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/prompts/select.rs
Expand Up @@ -256,7 +256,7 @@ impl Select<'_> {
term.flush()?;

match term.read_key()? {
Key::ArrowDown | Key::Char('j') => {
Key::ArrowDown | Key::Tab | Key::Char('j') => {
if sel == !0 {
sel = 0;
} else {
Expand All @@ -275,7 +275,7 @@ impl Select<'_> {
return Ok(None);
}
}
Key::ArrowUp | Key::Char('k') => {
Key::ArrowUp | Key::BackTab | Key::Char('k') => {
if sel == !0 {
sel = self.items.len() - 1;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/prompts/sort.rs
Expand Up @@ -188,7 +188,7 @@ impl Sort<'_> {
term.flush()?;

match term.read_key()? {
Key::ArrowDown | Key::Char('j') => {
Key::ArrowDown | Key::Tab | Key::Char('j') => {
let old_sel = sel;

if sel == !0 {
Expand All @@ -201,7 +201,7 @@ impl Sort<'_> {
order.swap(old_sel, sel);
}
}
Key::ArrowUp | Key::Char('k') => {
Key::ArrowUp | Key::BackTab | Key::Char('k') => {
let old_sel = sel;

if sel == !0 {
Expand Down