move focus after last file staged

This commit is contained in:
Stephan Dilly 2021-05-16 17:13:43 +02:00
parent d4455a2657
commit 8ddb3cdac5
4 changed files with 21 additions and 0 deletions

View file

@ -562,6 +562,9 @@ impl App {
self.push_tags_popup.push_tags()?;
flags.insert(NeedsUpdate::ALL)
}
InternalEvent::StatusLastFileMoved => {
self.status_tab.last_file_moved()?;
}
};
Ok(flags)

View file

@ -87,6 +87,12 @@ impl ChangesComponent {
_ => sync::stage_add_file(CWD, path)?,
};
if self.is_empty() {
self.queue.borrow_mut().push_back(
InternalEvent::StatusLastFileMoved,
);
}
return Ok(true);
}
@ -274,6 +280,9 @@ impl Component for ChangesComponent {
} else {
self.stage_remove_all()?;
}
self.queue.borrow_mut().push_back(
InternalEvent::StatusLastFileMoved,
);
Ok(EventState::Consumed)
} else if e == self.key_config.status_reset_item
&& self.is_working_dir

View file

@ -48,6 +48,8 @@ pub enum InternalEvent {
ShowErrorMsg(String),
///
Update(NeedsUpdate),
///
StatusLastFileMoved,
/// open commit msg input
OpenCommit,
///

View file

@ -437,6 +437,13 @@ impl Status {
}
}
pub fn last_file_moved(&mut self) -> Result<()> {
if !self.is_focus_on_diff() && self.is_visible() {
self.switch_focus(self.focus.toggled_focus())?;
}
Ok(())
}
fn push(&self, force: bool) {
if self.can_push() {
if let Some(branch) = self.git_branch_name.last() {