Skip to content

[diff/editor] Add Find-in-file replace support#817

Merged
mdo merged 3 commits into
beta-1.3from
editor/replace
Jun 16, 2026
Merged

[diff/editor] Add Find-in-file replace support#817
mdo merged 3 commits into
beta-1.3from
editor/replace

Conversation

@ije

@ije ije commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator
  • Replace functional
  • Dom layout
  • UI deisign @mdo

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pierre-docs-diffs Ready Ready Preview Jun 16, 2026 7:03pm
pierre-docs-diffshub Ready Ready Preview Jun 16, 2026 7:03pm
pierre-docs-trees Ready Ready Preview Jun 16, 2026 7:03pm
pierrejs-diff-demo Ready Ready Preview Jun 16, 2026 7:03pm

Request Review

@necolas necolas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 48bbf0da53

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2212 to +2214
true,
this.#selections
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Record post-replace selections for history

When Replace/Replace All records the edit with updateHistory but only provides selectionsBefore, the edit stack stores selectionsAfter as undefined; after a user replaces a match, undoes it, and then redoes it, redo() calls #applyChange without selections and the editor keeps the stale pre-redo selection/caret. Compute and pass the collapsed/next selection (or set it on the undo entry) so redo restores a valid editor state.

Useful? React with 👍 / 👎.

Comment on lines +1018 to +1021
const re = new RegExp(pattern.source, pattern.flags.replace('g', ''));
const match = re.exec(matched);
if (match === null || match[0].length !== matched.length) {
return searchParams.replaceText;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve regex context when expanding replacements

For regexes whose match depends on context outside the consumed text, search still finds the match, but replacement expansion reruns the pattern against only matched. For example (?<=foo)(bar) on foobar matches [3,6], but re.exec('bar') fails here, so $1/$& are inserted literally instead of expanding. Run the regex against the full line at the original index, or carry the original match result from search, before expanding the replacement.

Useful? React with 👍 / 👎.

@mdo mdo merged commit c7786d8 into beta-1.3 Jun 16, 2026
8 checks passed
@mdo mdo deleted the editor/replace branch June 16, 2026 23:09
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.

3 participants