Skip to content

fix(edit): preserve leading whitespace in TrimmedBoundaryReplacer#29995

Open
levgiorg wants to merge 1 commit into
anomalyco:devfrom
levgiorg:fix/issue-29573-edit-whitespace
Open

fix(edit): preserve leading whitespace in TrimmedBoundaryReplacer#29995
levgiorg wants to merge 1 commit into
anomalyco:devfrom
levgiorg:fix/issue-29573-edit-whitespace

Conversation

@levgiorg
Copy link
Copy Markdown

Issue for this PR

Closes #29573

Type of change

  • Bug fix

What does this PR do?

Fixes TrimmedBoundaryReplacer which yielded trimmed search text (find.trim()) without indentation context. The content.indexOf(trimmedFind) call found the match AFTER leading whitespace, but content.substring(0, index) preserved those leading spaces. The concatenation then produced doubled indentation. The fix removes the direct trimmedFind yield — only blocks matched from actual file content (with correct indentation) are yielded.

How did you verify your code works?

  • TypeScript typecheck passes
  • Existing tests pass (50/50)

Screenshots / recordings

Not applicable — no UI change.

Checklist

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

The TrimmedBoundaryReplacer yielded trimmedFind (find.trim()) without leading
whitespace context. content.indexOf(trimmedFind) skipped past indentation, but
content.substring(0, index) preserved the original whitespace, causing doubled
indentation on replacement. Remove the direct trimmedFind yield — only yield
blocks matched from actual content with correct indentation.

Fixes anomalyco#29573
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 tool strips leading whitespace from first line of replacement block

1 participant