Repository navigation
fix: allow replace all with an empty replacement - #3048
Merged
bajrangCoder merged 2 commits intoNov 13, 2026
Merged
bajrangCoder merged 2 commits into
bajrangCoder merged 2 commits into
Conversation
Search in files returned early from replaceAll() when the replace field was empty, so there was no way to delete every match. Both the worker and the native replace already handle an empty string, so only the search query is required now. Fixes Acode-Foundation#3044
Contributor
[Medium impact] The PR appears safe to merge; no new actionable issues were found. SummaryAllows “replace all” to delete matches with an empty replacement.
The previous unnumbered finding is fixed: Reviews (3) · Last reviewed commit: "fix: keep empty replacement text for fil..." · Reviewed by Greptile |
openFile ignored supplied text when it was an empty string, so a closed file whose whole content was replaced with "" was reloaded from disk.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3044
Problem
In search in files, "replace all" did nothing when the replace field was empty, so there was no way to delete every match.
replaceAll()returned early withif (!search || !replace) return;, and an empty string is falsy.Fix
Only the search query is required now. The two replace paths already handle an empty replacement:
content.replace(search, "")WorkspaceIndex.runSearch):replace == null ? "" : replace, thenreplaceAllTests
New
tests/unit/searchReplaceAll.test.js(samevm+ source slice style assearchStreamingResults.test.js):replace-files,"")replace,"")The first two fail on
mainand pass with this change.npx vitest run: 862 tests, the only failures are the 4 LSP test files that import@codemirror/lsp-clientfrom thecodemirror-lsp-clientsubmodule, which I did not check out (same onmain).biome checkis clean on the changed files.I did not test this on a device.