Skip to content

search: Fix replace all being silently dropped#50852

Merged
osiewicz merged 2 commits intozed-industries:mainfrom
OmChillure:fix-replace-all
Mar 19, 2026
Merged

search: Fix replace all being silently dropped#50852
osiewicz merged 2 commits intozed-industries:mainfrom
OmChillure:fix-replace-all

Conversation

@OmChillure
Copy link
Copy Markdown
Contributor

Fixes #50848

Problem

When Replace All was triggered with a stale search query (i.e., the query text had changed since the last completed search), the old code ould restart the search and immediately return, silently discarding the replace-all intent. This caused the Replace All action to appear to do nothing on the first try, only working on subsequent attempts once results were already loaded.

Fix :

Fix this by introducing a pending_replace_all flag on ProjectSearchView. When Replace All is invoked while a search is in
flight or the query is stale, the flag is set and the action is deferred.
Once the search completes and entity_changed is called, the flag is checked and replace_all is automatically dispatched.

Also disable the Replace Next button in the UI while a search is underway, since it cannot meaningfully act without up-to-date results.

Release Notes:

  • Fixed "Replace All" in project search not working on the first attempt when the search query was changed or results hadn't loaded yet.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 5, 2026
@maxdeviant maxdeviant changed the title fix replace all being silently dropped Fix replace all being silently dropped Mar 5, 2026
@maxdeviant maxdeviant changed the title Fix replace all being silently dropped search: Fix replace all being silently dropped Mar 5, 2026
@zelenenka zelenenka added the guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions label Mar 16, 2026
Copy link
Copy Markdown
Member

@osiewicz osiewicz left a comment

Choose a reason for hiding this comment

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

LGTM, sans a small nit

@osiewicz osiewicz enabled auto-merge (squash) March 19, 2026 15:11
@osiewicz osiewicz merged commit e5dc2f0 into zed-industries:main Mar 19, 2026
29 checks passed
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 20, 2026
Fixes zed-industries#50848

### Problem
When Replace All was triggered with a stale search query (i.e., the
query text had changed since the last completed search), the old code
ould restart the search and immediately return, silently discarding the
replace-all intent. This caused the Replace All action to appear to do
nothing on the first try, only working on subsequent attempts once
results were already loaded.

### Fix :
Fix this by introducing a `pending_replace_all` flag on
ProjectSearchView. When Replace All is invoked while a search is in
flight or the query is stale, the flag is set and the action is
deferred.
Once the search completes and `entity_changed` is called, the flag is
checked and `replace_all` is automatically dispatched.

Also disable the Replace Next button in the UI while a search is
underway, since it cannot meaningfully act without up-to-date results.

### Release Notes:

- Fixed "Replace All" in project search not working on the first attempt
when the search query was changed or results hadn't loaded yet.
toshmukhamedov pushed a commit to toshmukhamedov/zed that referenced this pull request Mar 20, 2026
Fixes zed-industries#50848

### Problem
When Replace All was triggered with a stale search query (i.e., the
query text had changed since the last completed search), the old code
ould restart the search and immediately return, silently discarding the
replace-all intent. This caused the Replace All action to appear to do
nothing on the first try, only working on subsequent attempts once
results were already loaded.

### Fix :
Fix this by introducing a `pending_replace_all` flag on
ProjectSearchView. When Replace All is invoked while a search is in
flight or the query is stale, the flag is set and the action is
deferred.
Once the search completes and `entity_changed` is called, the flag is
checked and `replace_all` is automatically dispatched.

Also disable the Replace Next button in the UI while a search is
underway, since it cannot meaningfully act without up-to-date results.

### Release Notes:

- Fixed "Replace All" in project search not working on the first attempt
when the search query was changed or results hadn't loaded yet.
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 23, 2026
Fixes zed-industries#50848

### Problem
When Replace All was triggered with a stale search query (i.e., the
query text had changed since the last completed search), the old code
ould restart the search and immediately return, silently discarding the
replace-all intent. This caused the Replace All action to appear to do
nothing on the first try, only working on subsequent attempts once
results were already loaded.

### Fix :
Fix this by introducing a `pending_replace_all` flag on
ProjectSearchView. When Replace All is invoked while a search is in
flight or the query is stale, the flag is set and the action is
deferred.
Once the search completes and `entity_changed` is called, the flag is
checked and `replace_all` is automatically dispatched.

Also disable the Replace Next button in the UI while a search is
underway, since it cannot meaningfully act without up-to-date results.

### Release Notes:

- Fixed "Replace All" in project search not working on the first attempt
when the search query was changed or results hadn't loaded yet.
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 guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Find and Replace All only works the 2nd time you open Zed

3 participants