Skip to content

Commit

Permalink
alt+q to abort query when in editor insert mode (#87)
Browse files Browse the repository at this point in the history
* update editor abort keybinding

* q to abort in normal mode
  • Loading branch information
achristmascarl authored Sep 18, 2024
1 parent 4ad1edb commit 4c1dd0b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .config/rainfrog_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"<Backtab>" = "CycleFocusBackwards"

[keybindings.Editor]
"q" = "AbortQuery"
"<Alt-q>" = "AbortQuery"
"<F5>" = "SubmitEditorQuery"
"<Alt-1>" = "FocusMenu"
"<Alt-2>" = "FocusEditor"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ rainfrog --url $(connection_url)
| `Alt+4`, `Ctrl+g` | change focus to results |
| `Tab` | cycle focus forwards |
| `Shift+Tab` | cycle focus backwards |
| `q` | abort current query |
| `q`, `Alt+q` in query editor | abort current query |

### menu (list of schemas and tables)
| keybinding | description |
Expand Down
1 change: 1 addition & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ impl<'a> App<'a> {
"{}{}",
match self.state.query_task {
None => "",
_ if self.state.focus == Focus::Editor => "[<alt + q>] abort ",
_ if self.state.focus != Focus::PopUp => "[q] abort ",
_ => ""
},
Expand Down
5 changes: 5 additions & 0 deletions src/components/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ impl<'a> Editor<'a> {
sender.send(Action::Quit)?;
}
},
Input { key: Key::Char('q'), .. } if matches!(self.vim_state.mode, Mode::Normal) => {
if let Some(sender) = &self.command_tx {
sender.send(Action::AbortQuery)?;
}
},
_ => {
let new_vim_state = self.vim_state.clone();
self.vim_state = match new_vim_state.transition(input, &mut self.textarea) {
Expand Down

0 comments on commit 4c1dd0b

Please sign in to comment.