Fix stashlist after marked drop (#1207)

This commit is contained in:
Stephan D 2022-04-23 18:01:15 +01:00 committed by GitHub
parent 96aa346292
commit 02efae1499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 8 deletions

View File

@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* opening tags list without remotes ([#1111](https://github.com/extrawurst/gitui/issues/1111))
* tabs indentation in blame [[@fersilva16](https://github.com/fersilva16)] ([#1111](https://github.com/extrawurst/gitui/issues/1117))
* switch focus to index after staging last file ([#1169](https://github.com/extrawurst/gitui/pull/1169))
* fix stashlist multi marking not updated after dropping ([#1207](https://github.com/extrawurst/gitui/pull/1207))
## [0.20.1] - 2021-01-26

View File

@ -865,10 +865,10 @@ impl App {
}
}
Action::StashDrop(_) | Action::StashPop(_) => {
if let Err(e) = StashList::action_confirmed(
&self.repo.borrow(),
&action,
) {
if let Err(e) = self
.stashlist_tab
.action_confirmed(&self.repo.borrow(), &action)
{
self.queue.push(InternalEvent::ShowErrorMsg(
e.to_string(),
));

View File

@ -138,6 +138,11 @@ impl CommitList {
&self.marked
}
///
pub fn clear_marked(&mut self) {
self.marked.clear();
}
pub fn copy_entry_hash(&self) -> Result<()> {
if let Some(e) = self.items.iter().nth(
self.selection.saturating_sub(self.items.index_offset()),

View File

@ -107,28 +107,40 @@ impl StashList {
/// Called when a pending stash action has been confirmed
pub fn action_confirmed(
&mut self,
repo: &RepoPath,
action: &Action,
) -> Result<()> {
match action {
Action::StashDrop(ids) => Self::drop(repo, ids)?,
Action::StashPop(id) => Self::pop(repo, *id)?,
Action::StashDrop(ids) => self.drop(repo, ids)?,
Action::StashPop(id) => self.pop(repo, *id)?,
_ => (),
};
Ok(())
}
fn drop(repo: &RepoPath, ids: &[CommitId]) -> Result<()> {
fn drop(
&mut self,
repo: &RepoPath,
ids: &[CommitId],
) -> Result<()> {
for id in ids {
sync::stash_drop(repo, *id)?;
}
self.list.clear_marked();
self.update()?;
Ok(())
}
fn pop(repo: &RepoPath, id: CommitId) -> Result<()> {
fn pop(&mut self, repo: &RepoPath, id: CommitId) -> Result<()> {
sync::stash_pop(repo, id)?;
self.list.clear_marked();
self.update()?;
Ok(())
}
}