-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 possible crash when deleting a branch while filtering is active #4195
Fix possible crash when deleting a branch while filtering is active #4195
Conversation
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more Footnotes
|
nice, makes sense |
9bd4ce7
to
c20badb
Compare
@jesseduffield Finally got around to adding a test, so this is ready now. (I verified that the test crashes when reverting the fix.) |
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 one
The code that tries to reselect the same branch again uses GetItems, which in case of filtering is the filtered list. After replacing the branches slice with a new one, the filtered list is no longer up to date, so we must reapply the filter before working with it. It so happens that refreshView does that, so simply call that before setting the selection again; I don't think the order matters in this case. Otherwise we'd have to insert another call to ReApplyFilter before the call to GetItems, which we can avoid this way. Note that this doesn't actually make anything work better in the case of deleting a branch, since we can't reselect the deleted branch anyway of course. But it avoids a possible crash if the branch that was deleted was the last one in the unfiltered list.
c20badb
to
ff4ae4a
Compare
Fix #4179.
go generate ./...
)