Skip to content

Add specific key bindings to stage / unstage items #930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
- 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))

## Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/components/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl Component for ChangesComponent {

if self.focused() {
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!(
self,
"staging error:",
Expand Down
2 changes: 1 addition & 1 deletion src/components/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ impl Component for DiffComponent {
} else if e == self.key_config.page_down {
self.move_selection(ScrollType::PageDown);
Ok(EventState::Consumed)
} else if e == self.key_config.enter
} else if e == self.key_config.stage_unstage_item
&& !self.is_immutable
{
try_or_popup!(
Expand Down
2 changes: 2 additions & 0 deletions src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub struct KeyConfig {
pub pull: KeyEvent,
pub abort_merge: KeyEvent,
pub undo_commit: KeyEvent,
pub stage_unstage_item: KeyEvent,
}

#[rustfmt::skip]
Expand Down Expand Up @@ -161,6 +162,7 @@ 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_unstage_item: KeyEvent { code: KeyCode::Enter, modifiers: KeyModifiers::empty()},
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ pub mod commands {
CommandText::new(
format!(
"Add hunk [{}]",
key_config.get_hint(key_config.enter),
key_config.get_hint(key_config.stage_unstage_item),
),
"adds selected hunk to stage",
CMD_GROUP_DIFF,
Expand Down Expand Up @@ -586,7 +586,7 @@ pub mod commands {
CommandText::new(
format!(
"Remove hunk [{}]",
key_config.get_hint(key_config.enter),
key_config.get_hint(key_config.stage_unstage_item),
),
"removes selected hunk from stage",
CMD_GROUP_DIFF,
Expand Down Expand Up @@ -751,7 +751,7 @@ pub mod commands {
CommandText::new(
format!(
"Stage [{}]",
key_config.get_hint(key_config.enter),
key_config.get_hint(key_config.stage_unstage_item),
),
"stage currently selected file or entire path",
CMD_GROUP_CHANGES,
Expand All @@ -771,7 +771,7 @@ pub mod commands {
CommandText::new(
format!(
"Unstage [{}]",
key_config.get_hint(key_config.enter),
key_config.get_hint(key_config.stage_unstage_item),
),
"unstage currently selected file or entire path",
CMD_GROUP_CHANGES,
Expand Down
2 changes: 2 additions & 0 deletions vim_style_key_config.ron
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
open_file_tree: ( code: Char('F'), modifiers: ( bits: 1,),),
file_find: ( code: Char('f'), modifiers: ( bits: 0,),),

stage_unstage_item: ( code: Enter, modifiers: ( bits: 0,),),

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