Skip to content

fix(tools): use native ReplacePattern for editor_replace tool#39

Merged
CalvinAllen merged 1 commit intomainfrom
fix/tools/editor-replace-undo
Mar 16, 2026
Merged

fix(tools): use native ReplacePattern for editor_replace tool#39
CalvinAllen merged 1 commit intomainfrom
fix/tools/editor-replace-undo

Conversation

@CalvinAllen
Copy link
Contributor

Summary

  • Use TextDocument.ReplacePattern instead of deleting the entire file content and reinserting it, which caused an empty-file intermediate state in the undo history
  • Count matches with FindPattern before replacing, and return the count to the LLM (e.g., "Replaced 3 occurrence(s)")
  • Change ReplaceTextAsync return type from bool to int across the full RPC chain

Closes #37

Use TextDocument.ReplacePattern instead of deleting the entire file
content and reinserting it, which caused an empty-file intermediate
state in the undo history. Also returns the number of replacements
made for better LLM feedback.
@CalvinAllen CalvinAllen merged commit d6b4473 into main Mar 16, 2026
2 checks passed
@CalvinAllen CalvinAllen deleted the fix/tools/editor-replace-undo branch March 16, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

bug(tools): editor_replace tool clears whole file and writes it again

1 participant