Skip to content

fix: reset selection mode after deletion #4661

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

nileric
Copy link

@nileric nileric commented Jun 24, 2025

  • PR Description

Fixes selection state persistence after deletion by resetting selection mode.
Resolves #4612

  • Please check if the PR fulfills these requirements
  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

@stefanhaller stefanhaller added the bug Something isn't working label Jun 29, 2025
Copy link
Collaborator

@stefanhaller stefanhaller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for the contribution. I pushed two fixups; one is mentioned below, the other one fixes a failing test (6f9f305).

How much of an audit of the code did you do to find other cases? Or did you only fix the two cases mentioned in #4612? I think deleting branches in the remote branches panel (the one that you get when pressing enter on a remote) is also still broken, not sure if there are any others.

@@ -557,6 +557,7 @@ func (self *BranchesController) delete(branches []*models.Branch) error {
Label: lo.Ternary(len(branches) > 1, self.c.Tr.DeleteLocalBranches, self.c.Tr.DeleteLocalBranch),
Key: 'c',
OnPress: func() error {
self.context().SetSelection(startIdx)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to do this only after deleting succeeded; if deleting the branches fails for whatever reason, the selection should stay unchanged. I pushed a fixup to change this (362a8f9).

@nileric
Copy link
Author

nileric commented Jun 29, 2025

@stefanhaller Thanks for fixups! I think I might have missed some more cases. I checked the panels with local commits, local branches and stashes. I'll try to check other panels later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deleting multiple items should reset selection mode
2 participants