Skip to content

Commit 21c875f

Browse files
committed
Apply changes based on feedback for FuzzySelect
- Rename `FuzzySelect::enable_vim_mode` to `FuzzySelect::vim_mode`. - Implement quitting in vim_mode. - Remove `vim_mode = false` when a character is entered.
1 parent 0488be6 commit 21c875f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/prompts/fuzzy_select.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl FuzzySelect<'_> {
125125
/// This then allows the user to navigate using hjkl.
126126
///
127127
/// The default is to disable vim mode.
128-
pub fn enable_vim_mode(mut self, val: bool) -> Self {
128+
pub fn vim_mode(mut self, val: bool) -> Self {
129129
self.enable_vim_mode = val;
130130
self
131131
}
@@ -255,17 +255,17 @@ impl FuzzySelect<'_> {
255255
term.flush()?;
256256

257257
match (term.read_key()?, sel, vim_mode) {
258-
(Key::Escape, _, _) if allow_quit && !self.enable_vim_mode => {
258+
(Key::Escape, _, false) if self.enable_vim_mode => {
259+
vim_mode = true;
260+
}
261+
(Key::Escape, _, _) if allow_quit => {
259262
if self.clear {
260263
render.clear()?;
261264
term.flush()?;
262265
}
263266
term.show_cursor()?;
264267
return Ok(None);
265268
}
266-
(Key::Escape, _, false) if self.enable_vim_mode => {
267-
vim_mode = true;
268-
}
269269
(Key::Char('i' | 'a'), _, true) => {
270270
vim_mode = false;
271271
}
@@ -342,7 +342,6 @@ impl FuzzySelect<'_> {
342342
term.flush()?;
343343
sel = Some(0);
344344
starting_row = 0;
345-
vim_mode = false;
346345
}
347346

348347
_ => {}

0 commit comments

Comments
 (0)