mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-22 11:03:25 +03:00
cleanup commands in status/diff (closes #572)
This commit is contained in:
parent
7d4b79606c
commit
37415259b1
@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- `[s]` key repurposed to trigger line based (un)stage
|
- `[s]` key repurposed to trigger line based (un)stage
|
||||||
|
- cleanup status/diff commands to be more context sensitive ([#572](https://github.com/extrawurst/gitui/issues/572))
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- support pull via rebase (using config `pull.rebase`) ([#566](https://github.com/extrawurst/gitui/issues/566))
|
- support pull via rebase (using config `pull.rebase`) ([#566](https://github.com/extrawurst/gitui/issues/566))
|
||||||
|
@ -675,12 +675,6 @@ impl Component for DiffComponent {
|
|||||||
self.focused,
|
self.focused,
|
||||||
));
|
));
|
||||||
|
|
||||||
out.push(CommandInfo::new(
|
|
||||||
strings::commands::copy(&self.key_config),
|
|
||||||
true,
|
|
||||||
self.focused,
|
|
||||||
));
|
|
||||||
|
|
||||||
out.push(
|
out.push(
|
||||||
CommandInfo::new(
|
CommandInfo::new(
|
||||||
strings::commands::diff_home_end(&self.key_config),
|
strings::commands::diff_home_end(&self.key_config),
|
||||||
@ -730,6 +724,12 @@ impl Component for DiffComponent {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out.push(CommandInfo::new(
|
||||||
|
strings::commands::copy(&self.key_config),
|
||||||
|
true,
|
||||||
|
self.focused,
|
||||||
|
));
|
||||||
|
|
||||||
CommandBlocking::PassingOn
|
CommandBlocking::PassingOn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,6 +232,10 @@ impl Status {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_focus_on_diff(&self) -> bool {
|
||||||
|
self.focus == Focus::Diff
|
||||||
|
}
|
||||||
|
|
||||||
fn switch_focus(&mut self, f: Focus) -> Result<bool> {
|
fn switch_focus(&mut self, f: Focus) -> Result<bool> {
|
||||||
if self.focus != f {
|
if self.focus != f {
|
||||||
self.focus = f;
|
self.focus = f;
|
||||||
@ -455,6 +459,8 @@ impl Component for Status {
|
|||||||
out: &mut Vec<CommandInfo>,
|
out: &mut Vec<CommandInfo>,
|
||||||
force_all: bool,
|
force_all: bool,
|
||||||
) -> CommandBlocking {
|
) -> CommandBlocking {
|
||||||
|
let focus_on_diff = self.is_focus_on_diff();
|
||||||
|
|
||||||
if self.visible || force_all {
|
if self.visible || force_all {
|
||||||
command_pump(
|
command_pump(
|
||||||
out,
|
out,
|
||||||
@ -467,30 +473,29 @@ impl Component for Status {
|
|||||||
&self.key_config,
|
&self.key_config,
|
||||||
),
|
),
|
||||||
true,
|
true,
|
||||||
true,
|
!focus_on_diff,
|
||||||
));
|
));
|
||||||
|
|
||||||
out.push(CommandInfo::new(
|
out.push(CommandInfo::new(
|
||||||
strings::commands::status_push(&self.key_config),
|
strings::commands::status_push(&self.key_config),
|
||||||
self.can_push(),
|
self.can_push(),
|
||||||
true,
|
!focus_on_diff,
|
||||||
));
|
));
|
||||||
out.push(CommandInfo::new(
|
out.push(CommandInfo::new(
|
||||||
strings::commands::status_force_push(
|
strings::commands::status_force_push(
|
||||||
&self.key_config,
|
&self.key_config,
|
||||||
),
|
),
|
||||||
self.can_push(),
|
|
||||||
true,
|
true,
|
||||||
|
self.can_push() && !focus_on_diff,
|
||||||
));
|
));
|
||||||
out.push(CommandInfo::new(
|
out.push(CommandInfo::new(
|
||||||
strings::commands::status_pull(&self.key_config),
|
strings::commands::status_pull(&self.key_config),
|
||||||
true,
|
true,
|
||||||
true,
|
!focus_on_diff,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let focus_on_diff = self.focus == Focus::Diff;
|
|
||||||
out.push(CommandInfo::new(
|
out.push(CommandInfo::new(
|
||||||
strings::commands::edit_item(&self.key_config),
|
strings::commands::edit_item(&self.key_config),
|
||||||
if focus_on_diff {
|
if focus_on_diff {
|
||||||
@ -510,17 +515,18 @@ impl Component for Status {
|
|||||||
self.can_focus_diff(),
|
self.can_focus_diff(),
|
||||||
(self.visible && !focus_on_diff) || force_all,
|
(self.visible && !focus_on_diff) || force_all,
|
||||||
));
|
));
|
||||||
}
|
|
||||||
|
|
||||||
out.push(
|
out.push(
|
||||||
CommandInfo::new(
|
CommandInfo::new(
|
||||||
strings::commands::select_status(&self.key_config),
|
strings::commands::select_status(
|
||||||
true,
|
&self.key_config,
|
||||||
(self.visible && self.focus == Focus::Diff)
|
),
|
||||||
|| force_all,
|
true,
|
||||||
)
|
(self.visible && !focus_on_diff) || force_all,
|
||||||
.hidden(),
|
)
|
||||||
);
|
.hidden(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
visibility_blocking(self)
|
visibility_blocking(self)
|
||||||
}
|
}
|
||||||
@ -535,7 +541,7 @@ impl Component for Status {
|
|||||||
if let Event::Key(k) = ev {
|
if let Event::Key(k) = ev {
|
||||||
return if k == self.key_config.edit_file
|
return if k == self.key_config.edit_file
|
||||||
&& (self.can_focus_diff()
|
&& (self.can_focus_diff()
|
||||||
|| self.focus == Focus::Diff)
|
|| self.is_focus_on_diff())
|
||||||
{
|
{
|
||||||
if let Some((path, _)) = self.selected_path() {
|
if let Some((path, _)) = self.selected_path() {
|
||||||
self.queue.borrow_mut().push_back(
|
self.queue.borrow_mut().push_back(
|
||||||
@ -564,18 +570,27 @@ impl Component for Status {
|
|||||||
&& !self.index_wd.is_empty()
|
&& !self.index_wd.is_empty()
|
||||||
{
|
{
|
||||||
self.switch_focus(Focus::WorkDir)
|
self.switch_focus(Focus::WorkDir)
|
||||||
} else if k == self.key_config.select_branch {
|
} else if k == self.key_config.select_branch
|
||||||
|
&& !self.is_focus_on_diff()
|
||||||
|
{
|
||||||
self.queue
|
self.queue
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push_back(InternalEvent::SelectBranch);
|
.push_back(InternalEvent::SelectBranch);
|
||||||
Ok(true)
|
Ok(true)
|
||||||
} else if k == self.key_config.force_push {
|
} else if k == self.key_config.force_push
|
||||||
|
&& !self.is_focus_on_diff()
|
||||||
|
&& self.can_push()
|
||||||
|
{
|
||||||
self.push(true);
|
self.push(true);
|
||||||
Ok(true)
|
Ok(true)
|
||||||
} else if k == self.key_config.push {
|
} else if k == self.key_config.push
|
||||||
|
&& !self.is_focus_on_diff()
|
||||||
|
{
|
||||||
self.push(false);
|
self.push(false);
|
||||||
Ok(true)
|
Ok(true)
|
||||||
} else if k == self.key_config.pull {
|
} else if k == self.key_config.pull
|
||||||
|
&& !self.is_focus_on_diff()
|
||||||
|
{
|
||||||
self.pull();
|
self.pull();
|
||||||
Ok(true)
|
Ok(true)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user