Skip to content

Commit fc2d731

Browse files
nyxnyxadamperkowski
authored
do not exit linutil in confirmation prompt when q is pressed (#758)
* do not exit linutil in confirmation prompt when q is pressed * remove cap support * add ``ctrl + c`` exiting Co-authored-by: Adam Perkowski <adas1per@protonmail.com> --------- Co-authored-by: nyx <nnyyxxxx@users.noreply.github.com> Co-authored-by: Adam Perkowski <adas1per@protonmail.com>
1 parent 72dfb29 commit fc2d731

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

tui/src/confirmation.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl FloatContent for ConfirmPrompt {
8888
use KeyCode::*;
8989
self.status = match key.code {
9090
Char('y') | Char('Y') => ConfirmStatus::Confirm,
91-
Char('n') | Char('N') | Esc => ConfirmStatus::Abort,
91+
Char('n') | Char('N') | Esc | Char('q') => ConfirmStatus::Abort,
9292
Char('j') => {
9393
self.scroll_down();
9494
ConfirmStatus::None
@@ -116,10 +116,10 @@ impl FloatContent for ConfirmPrompt {
116116
"Confirmation prompt",
117117
Box::new([
118118
Shortcut::new("Continue", ["Y", "y"]),
119-
Shortcut::new("Abort", ["N", "n"]),
120-
Shortcut::new("Scroll up", ["j"]),
121-
Shortcut::new("Scroll down", ["k"]),
122-
Shortcut::new("Close linutil", ["CTRL-c", "q"]),
119+
Shortcut::new("Abort", ["N", "n", "q", "Esc"]),
120+
Shortcut::new("Scroll up", ["k"]),
121+
Shortcut::new("Scroll down", ["j"]),
122+
Shortcut::new("Close linutil", ["CTRL-c"]),
123123
]),
124124
)
125125
}

tui/src/state.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,15 @@ impl AppState {
420420
// This should be defined first to allow closing
421421
// the application even when not drawable ( If terminal is small )
422422
// Exit on 'q' or 'Ctrl-c' input
423-
if matches!(
424-
self.focus,
425-
Focus::TabList | Focus::List | Focus::ConfirmationPrompt(_)
426-
) && (key.code == KeyCode::Char('q')
427-
|| key.modifiers.contains(KeyModifiers::CONTROL) && key.code == KeyCode::Char('c'))
423+
if matches!(self.focus, Focus::TabList | Focus::List)
424+
&& (key.code == KeyCode::Char('q')
425+
|| key.modifiers.contains(KeyModifiers::CONTROL) && key.code == KeyCode::Char('c'))
426+
{
427+
return false;
428+
}
429+
430+
if matches!(self.focus, Focus::ConfirmationPrompt(_))
431+
&& (key.modifiers.contains(KeyModifiers::CONTROL) && key.code == KeyCode::Char('c'))
428432
{
429433
return false;
430434
}

0 commit comments

Comments
 (0)