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 db55507
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Added
- support rebasing branches with conflicts ([#895](https://github.com/extrawurst/gitui/issues/895))
- specific key bindings to stage / unstage items [[@alessandroasm](https://github.com/alessandroasm)] ([#909](https://github.com/extrawurst/gitui/issues/909))

## Fixed
- appropriate error message when pulling deleted remote branch ([#911](https://github.com/extrawurst/gitui/issues/991))
Expand Down
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
3 changes: 3 additions & 0 deletions vim_style_key_config.ron
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@
open_file_tree: ( code: Char('F'), modifiers: ( bits: 1,),),
file_find: ( code: Char('f'), modifiers: ( bits: 0,),),

stage_item: ( code: Enter, modifiers: ( bits: 0,),),
unstage_item: ( code: Enter, modifiers: ( bits: 0,),),

//removed in 0.11
//tab_toggle_reverse_windows: ( code: BackTab, modifiers: ( bits: 1,),),
)

0 comments on commit db55507

Please sign in to comment.