From ef4ade1fd95b900d8f1d7680e72efbd23e5a503c Mon Sep 17 00:00:00 2001 From: extrawurst Date: Sat, 23 Apr 2022 18:29:36 +0200 Subject: [PATCH 1/3] fix stashlist not updated after dropping marked --- src/app.rs | 8 ++++---- src/components/commitlist.rs | 5 +++++ src/tabs/stashlist.rs | 12 ++++++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/app.rs b/src/app.rs index 5cfc7eb38a..2425dd7531 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 00f264167b..7ef6cc0ebf 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 3b39cf55de..7f536bccd1 100644 --- a/src/tabs/stashlist.rs +++ b/src/tabs/stashlist.rs @@ -107,11 +107,12 @@ 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::StashDrop(ids) => self.drop(repo, ids)?, Action::StashPop(id) => Self::pop(repo, *id)?, _ => (), }; @@ -119,11 +120,18 @@ impl StashList { 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(()) } From 5ba6099e6b277a3c146f715975e6773b04e5f33a Mon Sep 17 00:00:00 2001 From: extrawurst Date: Sat, 23 Apr 2022 18:31:06 +0200 Subject: [PATCH 2/3] also update list after pop --- src/tabs/stashlist.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tabs/stashlist.rs b/src/tabs/stashlist.rs index 7f536bccd1..e4e5efae56 100644 --- a/src/tabs/stashlist.rs +++ b/src/tabs/stashlist.rs @@ -113,7 +113,7 @@ impl StashList { ) -> Result<()> { match action { Action::StashDrop(ids) => self.drop(repo, ids)?, - Action::StashPop(id) => Self::pop(repo, *id)?, + Action::StashPop(id) => self.pop(repo, *id)?, _ => (), }; @@ -135,8 +135,12 @@ impl StashList { 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(()) } } From 9d98778b940401b38be1ea40212cbec4f8da78c8 Mon Sep 17 00:00:00 2001 From: extrawurst Date: Sat, 23 Apr 2022 18:37:43 +0200 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19979ccc79..49b575fb6a 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