-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Collapse selection after deleting a range of branches or stashes #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
Collapse selection after deleting a range of branches or stashes #4661
Conversation
There was a problem hiding this 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.
| Label: lo.Ternary(len(branches) > 1, self.c.Tr.DeleteLocalBranches, self.c.Tr.DeleteLocalBranch), | ||
| Key: 'c', | ||
| OnPress: func() error { | ||
| self.context().SetSelection(startIdx) |
There was a problem hiding this comment.
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).
|
@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 |
We had code already that was supposed to do this, but it didn't work. It should have used SetSelection() instead of SetSelectedLineIdx(); the latter doesn't actually cancel a range selection. Introduce a new function specifically for collapsing the range after deleting multiple items, so that clients don't need two calls (we'll add a bunch more in this branch).
We only want to do this when the function is called from the remote branches panel. It can also be called with a selection of local branches in order to delete their remote branches, but in this case the selection shouldn't be collapsed because the local branches stay around.
6f9f305 to
bc0cddf
Compare
|
@nileric I looked at your changes again, and found that they were not quite correct yet for the case of deleting remote branches from the local branches panel, in which case we don't want to collapse the selection. Also, I found a bit of a nicer way to do the fixes; I force-pushed your branch with these changes. I'm afraid there's not much left of your original PR now, hope you don't mind. 😄 |
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [jesseduffield/lazygit](https://github.com/jesseduffield/lazygit) | minor | `v0.52.0` -> `v0.53.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>jesseduffield/lazygit (jesseduffield/lazygit)</summary> ### [`v0.53.0`](https://github.com/jesseduffield/lazygit/releases/tag/v0.53.0) [Compare Source](jesseduffield/lazygit@v0.52.0...v0.53.0) <!-- Release notes generated using configuration in .github/release.yml at v0.53.0 --> This is the first lazygit release after Jesse [passed the maintainership to me](jesseduffield/lazygit#4655) ([@​stefanhaller](https://github.com/stefanhaller)), and I'm excited (and a little bit nervous 😄) about it. No big new features this time, but lots of smaller quality-of-life improvements. The one that makes the biggest difference for me is an improved hunk selection mode in the staging view (in case you didn't know, you can switch from the normal line selection mode to hunk mode by pressing `a`). This now works a bit more fine-grained, by selecting groups of added or deleted lines rather than entire hunks, which often consist of several such groups. With this change I find that I prefer hunk mode over line mode in most cases, so I added a user config to switch to hunk automatically upon entering the staging view; it is off by default, but I encourage you to enable it (`gui.useHunkModeInStagingView`) to see if you like it as much as I do. Feedback about this is welcome; please comment on [the MR](jesseduffield/lazygit#4684) if you have any. The detailed list of all changes follows: #### What's Changed ##### Enhancements 🔥 - Add option to disable warning when amending last commit by [@​johnhamlin](https://github.com/johnhamlin) in jesseduffield/lazygit#4640 - Add bold style for border by [@​aidancz](https://github.com/aidancz) in jesseduffield/lazygit#4644 - Add credential prompts for PKCS11-based SSH keys by [@​Jadeiin](https://github.com/Jadeiin) in jesseduffield/lazygit#4646 - Show annotation information for selected tag by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4663 - Show stash name for selected stash by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4673 - Auto-stash modified files when cherry-picking or reverting commits by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4683 - Move to next stageable line when adding a line to a custom patch by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4675 - Improve hunk selection mode in staging view by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4684 - Add user config to use hunk mode by default when entering staging view by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4685 ##### Fixes 🔧 - Fix stash operations when branch named 'stash' exists by [@​ChrisMcD1](https://github.com/ChrisMcD1) in jesseduffield/lazygit#4641 - Fix moving a custom patch from the very first commit of the history to a later commit by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4631 - Fix DEFAULT\_REMOTE\_ICON character code by [@​bedlamzd](https://github.com/bedlamzd) in jesseduffield/lazygit#4653 - Show GPG error before entering commit editor when rewording non-latest commits by [@​m04f](https://github.com/m04f) in jesseduffield/lazygit#4660 - Fix branch head icon appearing at head commit when a remote or tag exists with the same name as the current branch by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4669 - Fix applying custom patches to a dirty working tree by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4674 - Collapse selection after deleting a range of branches or stashes by [@​nileric](https://github.com/nileric) in jesseduffield/lazygit#4661 ##### Maintenance ⚙️ - Instantiate mutexes by value by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4632 - Bump github.com/cloudflare/circl from 1.6.0 to 1.6.1 by [@​dependabot](https://github.com/dependabot) in jesseduffield/lazygit#4633 - Update linter by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4671 - Some code cleanups to the "discard file changes from commit" feature by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4679 - Change Refresh to not return an error by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4680 ##### Docs 📖 - Fix formatting of a keyboard shortcut in the README.md by [@​DanOpcode](https://github.com/DanOpcode) in jesseduffield/lazygit#4678 ##### I18n 🌎 - Update translations from Crowdin by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4686 #### New Contributors - [@​johnhamlin](https://github.com/johnhamlin) made their first contribution in jesseduffield/lazygit#4640 - [@​aidancz](https://github.com/aidancz) made their first contribution in jesseduffield/lazygit#4644 - [@​bedlamzd](https://github.com/bedlamzd) made their first contribution in jesseduffield/lazygit#4653 - [@​Jadeiin](https://github.com/Jadeiin) made their first contribution in jesseduffield/lazygit#4646 - [@​m04f](https://github.com/m04f) made their first contribution in jesseduffield/lazygit#4660 - [@​DanOpcode](https://github.com/DanOpcode) made their first contribution in jesseduffield/lazygit#4678 - [@​nileric](https://github.com/nileric) made their first contribution in jesseduffield/lazygit#4661 **Full Changelog**: jesseduffield/lazygit@v0.52.0...v0.53.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC42Mi4xIiwidXBkYXRlZEluVmVyIjoiNDAuNjIuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Fixes selection state persistence after deletion by resetting selection mode.
Resolves #4612
go generate ./...)