Skip to content

Protect later saves during replace undo and correct search match positions - #48

Merged
Jignesh1236 merged 1 commit into
TheWonderlandStudio:mainfrom
harshitgupta31415:harshitgupta31415/fix-search-replace-safety
Oct 29, 2026
Merged

Jignesh1236 merged 1 commit into
TheWonderlandStudio:mainfrom
harshitgupta31415:harshitgupta31415/fix-search-replace-safety

Conversation

@harshitgupta31415

@harshitgupta31415 harshitgupta31415 commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

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 submatches array. For a line containing TODO 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 build passes, including renderer, preload and settings builds.
  • Syntax checks pass for all 38 tracked main-process, preload, build and tool JavaScript files, including node --check electron/main/index.js.
  • Local Electron reproduction with synthetic files confirms the reported behaviour.
  • User-visible strings are in English; the diff contains no secrets, keys or tokens.

Full desktop and terminal testing is limited by the Windows native node-pty rebuild requiring Visual Studio C++ build tools. The isolated search reproduction does not load that module.

@harshitgupta31415
harshitgupta31415 force-pushed the harshitgupta31415/fix-search-replace-safety branch from af78b7e to 0aa1ec1 Compare October 28, 2026 18:39
@Jignesh1236 Jignesh1236 self-assigned this Oct 28, 2026
@Jignesh1236
Jignesh1236 merged commit d223661 into TheWonderlandStudio:main Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search undercounts repeated matches and opens the wrong column with ripgrep Undo replace deletes edits saved after Replace All

2 participants