Repository navigation
Protect later saves during replace undo and correct search match positions - #48
Merged
Jignesh1236 merged 1 commit intoOct 29, 2026
Conversation
harshitgupta31415
force-pushed
the
harshitgupta31415/fix-search-replace-safety
branch
from
October 28, 2026 18:39
af78b7e to
0aa1ec1
Compare
Jignesh1236
approved these changes
Oct 28, 2026
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.
Closes #46
Closes #47
What changed and why
Undo replace used to write the whole old file back, even if someone had saved more work since the replacement. It now checks that the file still matches the replacement result before restoring it. Later saves stay intact, deleted files stay deleted, and a partial undo keeps only the skipped files available for a retry.
Search now reads each occurrence from ripgrep's
submatchesarray. For a line containingTODO TODO, the panel reports two matches instead of one and opens each occurrence at its own column. UTF-8 byte offsets are converted to the editor's UTF-16 columns, and split output chunks keep Unicode characters intact.Reproduction steps and small before/after examples are in the linked issues. The changes are limited to the search service, regression tests, and the test command.
Checks
npm test: seven regression tests pass; four fail against the original service.npm run buildpasses, including renderer, preload and settings builds.node --check electron/main/index.js.Full desktop and terminal testing is limited by the Windows native
node-ptyrebuild requiring Visual Studio C++ build tools. The isolated search reproduction does not load that module.