Skip to content

Commit

Permalink
fix: use <Tab> for completion confirming to avoid conflicts with th…
Browse files Browse the repository at this point in the history
…e Input component
  • Loading branch information
sxyazi committed Nov 7, 2023
1 parent 1f74481 commit 7c49d9c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
30 changes: 15 additions & 15 deletions yazi-config/preset/keymap.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,21 @@ keymap = [
{ on = [ "~" ], exec = "help", desc = "Open help" }
]

[completion]

keymap = [
{ on = [ "<C-q>" ], exec = "close", desc = "Cancel completion" },
{ on = [ "<Tab>" ], exec = "close --submit", desc = "Submit the completion" },

{ on = [ "<A-k>" ], exec = "arrow -1", desc = "Move cursor up" },
{ on = [ "<A-j>" ], exec = "arrow 1", desc = "Move cursor down" },

{ on = [ "<Up>" ], exec = "arrow -1", desc = "Move cursor up" },
{ on = [ "<Down>" ], exec = "arrow 1", desc = "Move cursor down" },

{ on = [ "~" ], exec = "help", desc = "Open help" }
]

[help]

keymap = [
Expand All @@ -237,18 +252,3 @@ keymap = [
# Filtering
{ on = [ "/" ], exec = "filter", desc = "Apply a filter for the help items" },
]

[completion]

keymap = [
{ on = [ "<C-q>" ], exec = "close", desc = "Cancel completion" },
{ on = [ "<Enter>" ], exec = "close --submit", desc = "Submit the completion" },

{ on = [ "<A-k>" ], exec = "arrow -1", desc = "Move cursor up" },
{ on = [ "<A-j>" ], exec = "arrow 1", desc = "Move cursor down" },

{ on = [ "<Up>" ], exec = "arrow -1", desc = "Move cursor up" },
{ on = [ "<Down>" ], exec = "arrow 1", desc = "Move cursor down" },

{ on = [ "~" ], exec = "help", desc = "Open help" }
]
18 changes: 9 additions & 9 deletions yazi-config/preset/theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,23 @@ permissions_s = { fg = "darkgray" }
# : }}}


# : Input {{{
# : Select {{{

[input]
[select]
border = { fg = "blue" }
title = {}
value = {}
selected = { reversed = true }
active = { fg = "magenta" }
inactive = {}

# : }}}


# : Select {{{
# : Input {{{

[select]
[input]
border = { fg = "blue" }
active = { fg = "magenta" }
inactive = {}
title = {}
value = {}
selected = { reversed = true }

# : }}}

Expand Down
4 changes: 4 additions & 0 deletions yazi-core/src/input/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ impl Input {
}

pub fn close(&mut self, submit: bool) -> bool {
if self.completion {
emit!(Call(Exec::call("close", vec![]).vec(), KeymapLayer::Completion));
}

if let Some(cb) = self.callback.take() {
let value = self.snap_mut().value.clone();
_ = cb.send(if submit { Ok(value) } else { Err(InputError::Canceled(value)) });
Expand Down

0 comments on commit 7c49d9c

Please sign in to comment.