Skip to content

Use multibuffer to fix symbol search when diff is present#52268

Merged
ConradIrwin merged 1 commit intozed-industries:mainfrom
Steven-Weng:symbol-search-fix
Apr 6, 2026
Merged

Use multibuffer to fix symbol search when diff is present#52268
ConradIrwin merged 1 commit intozed-industries:mainfrom
Steven-Weng:symbol-search-fix

Conversation

@Steven-Weng
Copy link
Copy Markdown
Contributor

@Steven-Weng Steven-Weng commented Mar 23, 2026

Context

Fixes a bug where project symbol search navigates to the wrong position when diff hunks are expanded. The cursor would land offset by the number of lines added by the expanded diffs (Closes #51331). Now, users navigating to symbols via project symbol search will land on the correct position even when diff hunks are expanded in the editor.

The fix converts the buffer position to a multi_buffer::Anchor before passing it to select_ranges, so it resolves correctly through the diff transform layer instead of being interpreted as a literal MultiBuffer coordinate.

Previously, the symbol's position was passed as a raw coordinate to the editor, which interpreted it relative to what's displayed on screen (including expanded diff lines). The fix converts the position to an anchor, which is tied to the actual content in the file rather than a screen position.

How to Review

  • All changes are in crates/project_symbols/src/project_symbols.rs. Most of the changes are in confirm() method (Lines 142-154).
    • There's also one change on the first line of the file.

Self-Review Checklist

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Fixed a bug where project symbols did not take you to the correct location when diffs are expanded.

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Mar 23, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @Steven-Weng on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-codeowner-coordinator zed-codeowner-coordinator bot requested review from a team, ConradIrwin and danilo-leal and removed request for a team March 23, 2026 22:54
@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Mar 23, 2026
@Steven-Weng
Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 24, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Mar 24, 2026

The cla-bot has been summoned, and re-checked this pull request!

@ConradIrwin
Copy link
Copy Markdown
Member

Thanks!

@ConradIrwin ConradIrwin enabled auto-merge (squash) March 24, 2026 14:58
@ConradIrwin
Copy link
Copy Markdown
Member

Can you please fix the linter?

auto-merge was automatically disabled March 27, 2026 05:44

Head branch was pushed to by a user without write access

@Steven-Weng
Copy link
Copy Markdown
Contributor Author

Fixed the formatting, combined the formatting fix commit and initial commit.

@ConradIrwin ConradIrwin merged commit 810822b into zed-industries:main Apr 6, 2026
30 checks passed
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 first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project Symbols does not go to correct line when diffs_expanded

3 participants