Skip to content

git_ui: Fix tree view next selection out of bounds#49283

Merged
kubkon merged 2 commits intozed-industries:mainfrom
errmayank:tree-view-select-next-out-of-bounds
Feb 17, 2026
Merged

git_ui: Fix tree view next selection out of bounds#49283
kubkon merged 2 commits intozed-industries:mainfrom
errmayank:tree-view-select-next-out-of-bounds

Conversation

@errmayank
Copy link
Contributor

Closes #49259

Before you mark this PR as ready for review, make sure that you have:

  • Added a solid test coverage and/or screenshots from doing manual testing
  • Done a self-review taking into account security and performance aspects
  • Aligned any UI changes with the UI checklist

Release Notes:

  • This change ensures that when the last visible collapsed directory is selected, the selection remains on that directory.

This change ensures that when the last visible collapsed directory is
selected, the selection remains on that directory.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 16, 2026
@github-actions github-actions bot added the community champion Issues filed by our amazing community champions! 🫶 label Feb 16, 2026
@RemcoSmitsDev
Copy link
Contributor

Nice, you beat me to it!

@kubkon kubkon requested review from kubkon and removed request for cameron1024 February 17, 2026 09:52
@kubkon kubkon assigned kubkon and unassigned cameron1024 Feb 17, 2026
Copy link
Member

@kubkon kubkon left a comment

Choose a reason for hiding this comment

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

Looks great! I've got a couple of nits though that hopefully are straightforward to address.

else {
return;
};
self.selected_entry = Some(new_selected_entry);
Copy link
Member

Choose a reason for hiding this comment

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

This check seems redundant:

  • in GitPanelViewMode::Flat, we already check for this
  • in GitPanelViewMode::Tree, next entry is bound by logical_indices precludes this case
    Lemme know if I missed something though! Also, your test does not account for this which strengthens my belief that this check is redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, i've updated it now

Comment on lines +7238 to +7247
".git": {},
"src": {
"a": {
"foo.rs": "fn foo() {}",
},
"b": {
"bar.rs": "fn bar() {}",
"baz.rs": "fn baz() {}",
},
},
Copy link
Member

Choose a reason for hiding this comment

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

Looks good! I would suggest we strive to replicate @mchisolm0's repro with one twist - let's add a GitHeader entry into the mix, so something like this:

Tracked
bar/
  bar1.py
  bar2.py
foo/
  foo1.py
  foo2.py
Untracked
foobar.py

@kubkon kubkon merged commit 96c72c2 into zed-industries:main Feb 17, 2026
27 checks passed
@kubkon
Copy link
Member

kubkon commented Feb 17, 2026

/cherry-pick preview

github-actions bot pushed a commit that referenced this pull request Feb 17, 2026
Closes #49259

Release Notes:

- This change ensures that when the last visible collapsed directory is
selected, the selection remains on that directory.
kubkon added a commit that referenced this pull request Feb 18, 2026
…ick to preview) (#49415)

Cherry-pick of #49283 to preview

----
Closes #49259

Release Notes:

- This change ensures that when the last visible collapsed directory is
selected, the selection remains on that directory.

---------

Co-authored-by: Mayank Verma <errmayank@gmail.com>
Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement community champion Issues filed by our amazing community champions! 🫶

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zed Editor Crashes When Navigating Between Files in Git Panel Tree View Using Keyboard

4 participants