This commit is contained in:
Stephan Dilly 2020-05-12 14:05:38 +02:00
parent a367238e05
commit c44966c1a9
5 changed files with 27 additions and 31 deletions

View file

@ -108,14 +108,6 @@ impl App {
flags.insert(NeedsUpdate::COMMANDS);
} else if let Event::Key(k) = ev {
let new_flags = match k {
//TODO: move into status tab
keys::OPEN_COMMIT
if self.status_tab.offer_open_commit_cmd() =>
{
self.commit.show();
NeedsUpdate::COMMANDS
}
keys::TAB_TOGGLE => {
self.toggle_tabs();
NeedsUpdate::COMMANDS
@ -265,6 +257,7 @@ impl App {
flags.insert(NeedsUpdate::ALL);
}
InternalEvent::Update(u) => flags.insert(u),
InternalEvent::OpenCommit => self.commit.show(),
};
flags

View file

@ -302,7 +302,7 @@ impl Component for ChangesComponent {
fn commands(
&self,
out: &mut Vec<CommandInfo>,
_force_all: bool,
force_all: bool,
) -> CommandBlocking {
let some_selection = self.selection().is_some();
@ -323,6 +323,14 @@ impl Component for ChangesComponent {
some_selection,
self.focused,
));
out.push(
CommandInfo::new(
commands::COMMIT_OPEN,
!self.is_empty(),
self.focused || force_all,
)
.order(-1),
);
}
out.push(CommandInfo::new(
@ -338,6 +346,15 @@ impl Component for ChangesComponent {
if self.focused {
if let Event::Key(e) = ev {
return match e {
keys::OPEN_COMMIT
if !self.is_working_dir
&& !self.is_empty() =>
{
self.queue
.borrow_mut()
.push_back(InternalEvent::OpenCommit);
true
}
keys::STATUS_STAGE_FILE => {
if self.index_add_remove() {
self.queue.borrow_mut().push_back(
@ -348,9 +365,10 @@ impl Component for ChangesComponent {
}
true
}
keys::STATUS_RESET_FILE => {
self.is_working_dir
&& self.dispatch_reset_workdir()
keys::STATUS_RESET_FILE
if self.is_working_dir =>
{
self.dispatch_reset_workdir()
}
keys::MOVE_DOWN => {
self.move_selection(MoveSelection::Down)

View file

@ -33,6 +33,8 @@ pub enum InternalEvent {
ShowMsg(String),
///
Update(NeedsUpdate),
///
OpenCommit,
}
///

View file

@ -14,7 +14,7 @@ pub static COMMIT_MSG: &str = "type commit message..";
pub static RESET_TITLE: &str = "Reset";
pub static RESET_MSG: &str = "confirm file reset?";
pub static HELP_TITLE: &str = "Help";
pub static HELP_TITLE: &str = "Help: all commands";
pub mod commands {
use crate::components::CommandText;
@ -100,7 +100,7 @@ pub mod commands {
///
pub static COMMIT_OPEN: CommandText = CommandText::new(
"Commit [c]",
"open commit view (available in non-empty stage)",
"open commit popup (available in non-empty stage)",
CMD_GROUP_COMMIT,
);
///

View file

@ -130,13 +130,6 @@ impl Status {
}
}
//TODO: unpub
pub fn offer_open_commit_cmd(&self) -> bool {
self.visible
&& self.diff_target == DiffTarget::Stage
&& !self.index.is_empty()
}
fn switch_focus(&mut self, f: Focus) -> bool {
if self.focus != f {
self.focus = f;
@ -273,16 +266,6 @@ impl Component for Status {
));
}
out.push(
CommandInfo::new(
commands::COMMIT_OPEN,
!self.index.is_empty(),
(self.visible && self.offer_open_commit_cmd())
|| force_all,
)
.order(-1),
);
out.push(
CommandInfo::new(
commands::SELECT_STATUS,