Skip to content

Commit e399dd8

Browse files
only quit from editor with ctrl+c if in normal mode (#65)
1 parent dd9e5f8 commit e399dd8

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

.config/rainfrog_config.toml

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"<Backtab>" = "CycleFocusBackwards"
1414

1515
[keybindings.Editor]
16-
"<Ctrl-c>" = "Quit"
1716
"q" = "AbortQuery"
1817
"<F5>" = "SubmitEditorQuery"
1918
"<Alt-1>" = "FocusMenu"

src/components/editor.rs

+5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ impl<'a> Editor<'a> {
8282
sender.send(Action::CycleFocusForwards)?;
8383
}
8484
},
85+
Input { key: Key::Char('c'), ctrl: true, .. } if matches!(self.vim_state.mode, Mode::Normal) => {
86+
if let Some(sender) = &self.command_tx {
87+
sender.send(Action::Quit)?;
88+
}
89+
},
8590
_ => {
8691
let new_vim_state = self.vim_state.clone();
8792
self.vim_state = match new_vim_state.transition(input, &mut self.textarea) {

src/vim.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,11 @@ impl Vim {
234234
textarea.move_cursor(CursorMove::End);
235235
return Transition::Mode(Mode::Visual);
236236
},
237-
Input { key: Key::Esc, .. } | Input { key: Key::Char('v'), ctrl: false, .. } if self.mode == Mode::Visual => {
237+
Input { key: Key::Esc, .. }
238+
| Input { key: Key::Char('c'), ctrl: true, .. }
239+
| Input { key: Key::Char('v'), ctrl: false, .. }
240+
if self.mode == Mode::Visual =>
241+
{
238242
textarea.cancel_selection();
239243
return Transition::Mode(Mode::Normal);
240244
},

0 commit comments

Comments
 (0)