Repository navigation
feat: replace text across the current folder - #636
Merged
Merged
Conversation
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.
Summary
Edit > Find and replace > Replace in folder...(Mod+Shift+H), or a toggle before the folder search field, shows a replacement field in the folder search view. While it shows, the search plans the replacement instead of stopping at the result limit: each match is shown struck through beside its replacement, skipped files keep their reasons, and a file that would not read as its matches replaced, such as a footnote label the replacement would duplicate, is skipped as refused. Planning writes nothing, andReplace allis offered only once the plan is complete and was made for the current query, options, and replacement.Replace alltransaction runs there, and save-time settling and the serializer produce its text. The open document is planned from a settled copy of its editor state, dispatching nothing.Replace allasks Save, Discard, or Cancel; the shared confirmation service gains a third action for this. Save or Discard runs the ordinary workflow and plans again without writing, so the updated preview is confirmed before anything is written.Replace allpreflights every planned file against the metadata and full-content fingerprint it was planned from, and checks that its text encodes strictly, through new bounded backend commands. It then writes in folder-relative-path order, checking each file again just before its staged atomic write. A stale file is left alone, a failed file does not stop the rest, and there is no cross-file transaction or Undo. The open document takes the replacement in its editor as oneUndostep and is saved through the save queue without prompts, so neither watcher mistakes Leafdown's writes for outside changes. A report in the sidebar lists the files replaced, changed since the plan, failed with their reason, and not attempted.CHANGELOG.mddescribe the feature.Related Issue
Closes #632
Verification
Focused tests:
Replace alland Save across the corpus, refuses a footnote label collision, and drops runs a deletion empties;Replace allavailability, progress, and the report;pnpm check:frontendandpnpm check:backendpass.A throwaway Vitest probe planned replacing
theacross 10,000 corpus-derived files (11.7 MB) with the real parser: about 110 s for 34,689 matches in 5,249 files, never holding the main thread longer than about 280 ms, roughly double search's per-file cost. 896 of those files fell back to a whole write.Not verified: the desktop E2E case added to the
folder-searchscenario, which replaces across the fixture folder with its open document and checks the files on disk and the absence of an external-change warning, was not run locally and is left to CI. Planning time was not measured in the release app, and the rendered sidebar was not inspected by hand.Notes