Skip to content

Commit d6ff197

Browse files
authored
Merge pull request #275 from theryangeary/master
add cmd+<0-9> to select item from list
2 parents 589a391 + 6503c91 commit d6ff197

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/app/tile.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,20 @@ impl Tile {
286286
Some(Message::ChangeFocus(ArrowKey::Down, 1))
287287
}
288288
keyboard::Key::Character(chr) => {
289-
if modifiers.command() && chr.to_string() == "r" {
289+
let s = chr.to_string();
290+
if modifiers.command() && s == "r" {
290291
Some(Message::ReloadConfig)
291-
} else if chr.to_string() == "p" && modifiers.control() {
292+
} else if modifiers.command() {
293+
s.parse::<usize>()
294+
.ok()
295+
.filter(|&n| n >= 1 && n <= 9)
296+
.map(|n| Message::OpenResult((n - 1) as u32))
297+
} else if s == "p" && modifiers.control() {
292298
Some(Message::ChangeFocus(ArrowKey::Up, 1))
293-
} else if chr.to_string() == "n" && modifiers.control() {
299+
} else if s == "n" && modifiers.control() {
294300
Some(Message::ChangeFocus(ArrowKey::Down, 1))
295301
} else {
296-
Some(Message::FocusTextInput(Move::Forwards(chr.to_string())))
302+
Some(Message::FocusTextInput(Move::Forwards(s)))
297303
}
298304
}
299305
keyboard::Key::Named(Named::Enter) => Some(Message::OpenFocused),

0 commit comments

Comments
 (0)