Skip to content

Commit

Permalink
Add specific key bindings to stage / unstage items
Browse files Browse the repository at this point in the history
Feature requested by Issue extrawurst#909.
  • Loading branch information
alessandroasm committed Oct 4, 2021
1 parent d359fab commit d9894ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,12 @@ impl Component for ChangesComponent {

if self.focused() {
if let Event::Key(e) = ev {
return if e == self.key_config.enter {
let stage_or_reset_key = if self.is_working_dir {
self.key_config.stage_item
} else {
self.key_config.unstage_item
};
return if e == stage_or_reset_key {
try_or_popup!(
self,
"staging error:",
Expand Down
4 changes: 4 additions & 0 deletions src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ pub struct KeyConfig {
pub pull: KeyEvent,
pub abort_merge: KeyEvent,
pub undo_commit: KeyEvent,
pub stage_item: KeyEvent,
pub unstage_item: KeyEvent,
}

#[rustfmt::skip]
Expand Down Expand Up @@ -161,6 +163,8 @@ impl Default for KeyConfig {
abort_merge: KeyEvent { code: KeyCode::Char('A'), modifiers: KeyModifiers::SHIFT},
open_file_tree: KeyEvent { code: KeyCode::Char('F'), modifiers: KeyModifiers::SHIFT},
file_find: KeyEvent { code: KeyCode::Char('f'), modifiers: KeyModifiers::empty()},
stage_item: KeyEvent { code: KeyCode::Enter, modifiers: KeyModifiers::empty()},
unstage_item: KeyEvent { code: KeyCode::Enter, modifiers: KeyModifiers::empty()},
}
}
}
Expand Down

0 comments on commit d9894ed

Please sign in to comment.