Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stashlist after marked drop #1207

Merged
merged 3 commits into from
Apr 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
));
Expand Down
5 changes: 5 additions & 0 deletions src/components/commitlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
20 changes: 16 additions & 4 deletions src/tabs/stashlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}
Expand Down