Add specific key bindings to stage / unstage items (#930)

* Add specific key bindings to stage / unstage items

Feature requested by Issue #909.

* Updating Help popup with stage / unstage keys

* Merging staging and unstaging into a single `stage_unstage_item` key

* Add/remove hunk now use the `stage_unstage_item` key
This commit is contained in:
Alessandro Menezes 2021-10-09 20:58:21 -04:00 committed by GitHub
parent 8486233053
commit 6ae5b5e2b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 6 deletions

View file

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Added ## Added
- support rebasing branches with conflicts ([#895](https://github.com/extrawurst/gitui/issues/895)) - support rebasing branches with conflicts ([#895](https://github.com/extrawurst/gitui/issues/895))
- add a key binding to stage / unstage items [[@alessandroasm](https://github.com/alessandroasm)] ([#909](https://github.com/extrawurst/gitui/issues/909))
- switch to status tab after merging or rebasing with conflicts ([#926](https://github.com/extrawurst/gitui/issues/926)) - switch to status tab after merging or rebasing with conflicts ([#926](https://github.com/extrawurst/gitui/issues/926))
## Fixed ## Fixed

View file

@ -233,7 +233,7 @@ impl Component for ChangesComponent {
if self.focused() { if self.focused() {
if let Event::Key(e) = ev { if let Event::Key(e) = ev {
return if e == self.key_config.enter { return if e == self.key_config.stage_unstage_item {
try_or_popup!( try_or_popup!(
self, self,
"staging error:", "staging error:",

View file

@ -738,7 +738,7 @@ impl Component for DiffComponent {
} else if e == self.key_config.page_down { } else if e == self.key_config.page_down {
self.move_selection(ScrollType::PageDown); self.move_selection(ScrollType::PageDown);
Ok(EventState::Consumed) Ok(EventState::Consumed)
} else if e == self.key_config.enter } else if e == self.key_config.stage_unstage_item
&& !self.is_immutable && !self.is_immutable
{ {
try_or_popup!( try_or_popup!(

View file

@ -88,6 +88,7 @@ pub struct KeyConfig {
pub pull: KeyEvent, pub pull: KeyEvent,
pub abort_merge: KeyEvent, pub abort_merge: KeyEvent,
pub undo_commit: KeyEvent, pub undo_commit: KeyEvent,
pub stage_unstage_item: KeyEvent,
} }
#[rustfmt::skip] #[rustfmt::skip]
@ -161,6 +162,7 @@ impl Default for KeyConfig {
abort_merge: KeyEvent { code: KeyCode::Char('A'), modifiers: KeyModifiers::SHIFT}, abort_merge: KeyEvent { code: KeyCode::Char('A'), modifiers: KeyModifiers::SHIFT},
open_file_tree: KeyEvent { code: KeyCode::Char('F'), modifiers: KeyModifiers::SHIFT}, open_file_tree: KeyEvent { code: KeyCode::Char('F'), modifiers: KeyModifiers::SHIFT},
file_find: KeyEvent { code: KeyCode::Char('f'), modifiers: KeyModifiers::empty()}, file_find: KeyEvent { code: KeyCode::Char('f'), modifiers: KeyModifiers::empty()},
stage_unstage_item: KeyEvent { code: KeyCode::Enter, modifiers: KeyModifiers::empty()},
} }
} }
} }

View file

@ -526,7 +526,7 @@ pub mod commands {
CommandText::new( CommandText::new(
format!( format!(
"Add hunk [{}]", "Add hunk [{}]",
key_config.get_hint(key_config.enter), key_config.get_hint(key_config.stage_unstage_item),
), ),
"adds selected hunk to stage", "adds selected hunk to stage",
CMD_GROUP_DIFF, CMD_GROUP_DIFF,
@ -586,7 +586,7 @@ pub mod commands {
CommandText::new( CommandText::new(
format!( format!(
"Remove hunk [{}]", "Remove hunk [{}]",
key_config.get_hint(key_config.enter), key_config.get_hint(key_config.stage_unstage_item),
), ),
"removes selected hunk from stage", "removes selected hunk from stage",
CMD_GROUP_DIFF, CMD_GROUP_DIFF,
@ -751,7 +751,7 @@ pub mod commands {
CommandText::new( CommandText::new(
format!( format!(
"Stage [{}]", "Stage [{}]",
key_config.get_hint(key_config.enter), key_config.get_hint(key_config.stage_unstage_item),
), ),
"stage currently selected file or entire path", "stage currently selected file or entire path",
CMD_GROUP_CHANGES, CMD_GROUP_CHANGES,
@ -771,7 +771,7 @@ pub mod commands {
CommandText::new( CommandText::new(
format!( format!(
"Unstage [{}]", "Unstage [{}]",
key_config.get_hint(key_config.enter), key_config.get_hint(key_config.stage_unstage_item),
), ),
"unstage currently selected file or entire path", "unstage currently selected file or entire path",
CMD_GROUP_CHANGES, CMD_GROUP_CHANGES,

View file

@ -100,6 +100,8 @@
open_file_tree: ( code: Char('F'), modifiers: ( bits: 1,),), open_file_tree: ( code: Char('F'), modifiers: ( bits: 1,),),
file_find: ( code: Char('f'), modifiers: ( bits: 0,),), file_find: ( code: Char('f'), modifiers: ( bits: 0,),),
stage_unstage_item: ( code: Enter, modifiers: ( bits: 0,),),
//removed in 0.11 //removed in 0.11
//tab_toggle_reverse_windows: ( code: BackTab, modifiers: ( bits: 1,),), //tab_toggle_reverse_windows: ( code: BackTab, modifiers: ( bits: 1,),),
) )