Zed Editor Fixes Project Search Bug with Selected Text in Split Git Diff

Zed fixes the bug where project search fails to get the query seed from old text selected on the left side of a side-by-side Git diff, and adds regression tests.
The Zed editor on the collab-production branch fixed a diff view interaction defect: when a user selects old text on the left side of a split Git diff and triggers project search, the search box cannot use the selected text as the query seed. The root cause is that a side-by-side diff is internally composed of two independent document buffers, and project search must determine which side the selection belongs to when deriving the query string; the old implementation missed handling for the left-side old-text buffer. After the fix, selections on both sides of a side-by-side diff and deleted text in a unified diff correctly populate the search seed. The commit adds three regression tests covering left-side old text, right-side new text, and unified diff deleted text, forming complete protection for the search seed logic. The commit also follows Zed's self-review and release note conventions.
Zed Editor Fixes Project Search Bug with Selected Text in Split Git Diff
Background
When viewing a Git diff in a code editor, developers often select a piece of code text and then directly initiate a project search. This interaction seems simple, but it involves the editor's understanding of the diff view structure. When the diff is presented in a split (side-by-side) form, with the old code on the left and the new code on the right, the editor needs to correctly determine which side the user has selected and use that text as the seed for the search.
A defect appeared in the Zed editor's collaboration branch collab-production: when a user selects text on the left side of a side-by-side diff, the project search cannot correctly use the selected text as the query seed. This issue was recorded in issue #67717 and prompted the fix in this commit.
Two Presentation Forms of Git Diff: A unified diff interleaves old and new code in a single column, with deleted lines marked by a - prefix and added lines by a + prefix; a side-by-side (split) diff places the old and new versions in two separate columns on the left and right, with the same logical line horizontally aligned on both sides. The underlying semantics are the same—both compare two snapshots of the same file—but the view structures differ greatly: the side-by-side view is actually composed of two independent editor buffers spliced together, each with its own coordinate system and text content. Therefore, when handling selection, cursor, syntax highlighting, and similar logic, the editor must first determine which side buffer the selection falls in and then map it to the corresponding document model. This is also why this defect only appears in the side-by-side view: the unified view has only one buffer, so there is no side determination issue.
Query Seed: Refers to the initial text used to initialize the query string when a project search is triggered. In a typical scenario, the user selects a piece of code and presses the project search shortcut; the editor fills the selected content into the search box as a starting point, and the user can continue editing from there. The source of the query seed can be the current selection, the word under the cursor, the clipboard, etc. For the editor, the key to generating the seed is translating the "selection on screen" into a "string in the document model"—in a normal single-buffer editor this step is straightforward, but in a composite view like a diff, it is necessary to first determine the buffer to which the selection belongs and then read the corresponding text from that buffer. If the mapping logic misses a buffer (such as the left-side old-text buffer of a side-by-side diff), the seed will be empty, and the search box will open with no initial query.
Fix Details
The core goal of this commit (95da826) is to fix the issue where the query seed cannot be correctly populated when project search is triggered from a selection on the left side of a side-by-side Git diff.
At the implementation level, when project search derives the query string from the selection, it needs to determine which diff side the selection belongs to. Previously, handling for the left side (old text) of a side-by-side diff was missing, so the selected text was not passed into the search query. After the fix, regardless of whether the user selects old text on the left side or new text on the right side of a side-by-side diff, project search can correctly obtain the selection content.
Interestingly, this issue only affects the side-by-side diff view, not the unified diff view. The conclusion given in the commit message is: project search fails to use the selected text on the left side of a side-by-side Git diff.
Regression Test Coverage
To ensure the fix is reliable and does not introduce regressions, the commit adds targeted regression tests covering three scenarios for project search deployment:
- Selecting old text on the left side of a side-by-side diff
- Selecting new text on the right side of a side-by-side diff
- Selecting deleted text in a unified diff
These three cases correspond to common sources of selections in diff views. They include both the left-side old-text scenario fixed in this commit and the existing behavior for right-side new text and deleted text in a unified diff, forming complete protection for the search seed logic.
Engineering Practice Observations
From this commit, we can see some conventions of the Zed team's collaborative development process. The commit message includes standard Summary, Testing, and Self-review checklists: the author confirms that the diff has been reviewed from the perspectives of quality, security, reliability, and performance, and checks off the test coverage item; the UI change checklist is unchecked, indicating that this change does not involve interface adjustments.
Fixes around diff view interactions like this are often more easily overlooked than split rendering itself. A diff view is usually composed internally of two document buffers, left and right, and selection coordinates need to be mapped back to the correct text buffer to obtain a meaningful string. The left buffer of a side-by-side view contains the old version content; if the search seed logic only retrieves values from the new version buffer, the left-side selection will come up empty. The regression tests cover both the left and right sides and the unified view, precisely to prevent this kind of "one side being missed" situation from recurring.
Diff Selection Scenarios in Regression Tests: Regression tests for diff views usually need to construct the view state (side-by-side/unified, selected side, selection start and end coordinates) together with the text buffer state, and then assert the final derived query string. The semantics of the three cases are different: left-side old text in a side-by-side diff corresponds to "content removed from the new version," right-side new text corresponds to "content currently present," and deleted text in a unified diff corresponds to "lines with deletion markers." They each go through different coordinate mapping branches; covering them means both verifying the left-side branch fixed in this commit and locking in the existing behavior of the right side and unified view so they are not accidentally changed. The value of such tests lies in turning a structural defect like "one side being missed" into an automatically detectable assertion, preventing similar problems from being reintroduced in future refactoring.
Release Notes
The Release Notes attached to the commit clearly state: Fix project search not using selected text on the left side of a side-by-side Git diff. For developers who are used to selecting diff snippets during code review for global search, this change makes interaction in the side-by-side view consistent with the unified view and the right-side new text.
If you use Zed's side-by-side diff and encounter an empty search box after selecting code on the left side, this fix directly addresses that experience gap.
One-line Summary
Zed fixes the defect where project search cannot obtain the query seed when old text is selected on the left side of a side-by-side Git diff, and adds regression tests.
Paragraph Summary
On the collaboration branch collab-production, the Zed editor fixed an interaction defect in the diff view: when a user selects old text on the left side of a split (side-by-side) Git diff and triggers project search, the search box cannot use the selected text as the query seed. The root cause is that a side-by-side diff is internally composed of two independent document buffers, left and right, and when project search derives the query string from the selection, it must first determine which side the selection belongs to; the old implementation missed handling for the left-side old-text buffer. After the fix, selections on both the left and right sides of a side-by-side diff, as well as deleted text in a unified diff, can correctly populate the search seed. The commit also adds three regression test cases covering left-side old text in a side-by-side diff, right-side new text in a side-by-side diff, and deleted text in a unified diff, forming complete protection for the search seed logic. The commit also follows the Zed team's self-review and release note conventions.
Related articles

Ditching pgvector: Migrating 1.7TB of Data to a Custom Rust Search Engine
A developer migrated 1.7 TB of data from pgvector to a custom Rust search engine, exploring vector retrieval bottlenecks at TB scale and the trade-offs of in-house solutions, providing a real-world case reference for vector database selection.

StratEdit: Editing 0.3% of Weights to Cure LLM Overthinking
StratEdit is a reinforcement-learning-free static weight editing method that modifies under 0.3% of weights to cut LLM thinking length by 57%, with zero inference overhead.

Jeff Dean's Startup Raises $1.2B Seed Round
Jeff Dean's startup has completed a $1.2B seed round, sparking discussion on Hacker News. This article analyzes the capital logic behind oversized seed rounds, Jeff Dean's technical background, and what this signals about the AI funding environment.