From 02efae149907b79fc1e81d303bffe4cfd6e489ca Mon Sep 17 00:00:00 2001 From: Stephan D <776816+extrawurst@users.noreply.github.com> Date: Sat, 23 Apr 2022 18:01:15 +0100 Subject: [PATCH] Fix stashlist after marked drop (#1207) --- CHANGELOG.md | 1 + src/app.rs | 8 ++++---- src/components/commitlist.rs | 5 +++++ src/tabs/stashlist.rs | 20 ++++++++++++++++---- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19979ccc..49b575fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/app.rs b/src/app.rs index 5cfc7eb3..2425dd75 100644 --- a/src/app.rs +++ b/src/app.rs @@ -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(), )); diff --git a/src/components/commitlist.rs b/src/components/commitlist.rs index 00f26416..7ef6cc0e 100644 --- a/src/components/commitlist.rs +++ b/src/components/commitlist.rs @@ -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()), diff --git a/src/tabs/stashlist.rs b/src/tabs/stashlist.rs index 3b39cf55..e4e5efae 100644 --- a/src/tabs/stashlist.rs +++ b/src/tabs/stashlist.rs @@ -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(()) } }