Skip to content

fix(opencode): reject ambiguous fuzzy edits - #41927

Open
nanami7777777 wants to merge 1 commit into
anomalyco:devfrom
nanami7777777:fuzzy-edit-ambiguity
Open

fix(opencode): reject ambiguous fuzzy edits#41927
nanami7777777 wants to merge 1 commit into
anomalyco:devfrom
nanami7777777:fuzzy-edit-ambiguity

Conversation

@nanami7777777

Copy link
Copy Markdown

Issue for this PR

Closes #41872

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The edit replacer now collects all spans found by a matching strategy before applying a change. If a fuzzy strategy matches multiple concrete spans and replaceAll is false, it reports the existing multiple-match error instead of editing the first byte-unique candidate. With replaceAll, it applies the replacement across the matched spans.

This keeps whitespace-normalized matches like alpha beta and alpha\tbeta from bypassing the ambiguity guard.

How did you verify your code works?

  • bun test test/tool/edit.test.ts in packages/opencode
  • bun typecheck in packages/opencode

Screenshots / recordings

N/A; this is not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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.

edit fuzzy replacers can bypass multiple-match ambiguity when equivalent candidates differ in whitespace

1 participant