Skip to content

fix(tools): normalize line endings on document write and replace operations#93

Open
Gh61 wants to merge 1 commit into
CodingWithCalvin:mainfrom
Gh61:fix/tools/normalize-line-endings
Open

fix(tools): normalize line endings on document write and replace operations#93
Gh61 wants to merge 1 commit into
CodingWithCalvin:mainfrom
Gh61:fix/tools/normalize-line-endings

Conversation

@Gh61

@Gh61 Gh61 commented Jun 8, 2026

Copy link
Copy Markdown

Hi, thank you for this extension. I use it almost daily when working with Visual Studio.
I came across an issue that has been causing some inconvenience, so I tried to implement a fix for it.
More details are below.

Description

Agents receive document content with LF line endings but write back with LF regardless of the document native line ending (CRLF on Windows).
This caused two issues:

  • document_write and editor_insert silently converted CRLF files (or its parts) to LF
  • editor_replace might fail to find multi-line patterns because \n in the search text didn't match \r\n in the document buffer

Changes:

  • detect document line ending via VS ITextBuffer snapshot (same source as the status bar CRLF/LF indicator), with content scan as fallback
  • normalize incoming content to the document native line ending indocument_write, editor_replace, and editor_insert
  • document_read now consistently outputs LF so agents always see \n

Type of Change

  • feat - New feature
  • fix - Bug fix
  • docs - Documentation only
  • refactor - Code change that neither fixes a bug nor adds a feature
  • test - Adding or updating tests
  • chore - Maintenance tasks
  • ci - CI/CD changes

Checklist

  • My code follows the project's code style
  • I have tested my changes locally
  • I have updated documentation if needed
  • My commits follow the conventional commit format
  • This PR has a descriptive title using conventional commit format

…ations

Agents receive document content with LF line endings but write back
with LF regardless of the document native line ending (CRLF on Windows).

- detect document line ending via VS ITextBuffer snapshot (same source
  as the status bar CRLF/LF indicator), with content scan as fallback
- normalize incoming content to the document native line ending in
  document_write, editor_replace, and editor_insert
- document_read now consistently outputs LF so agents always see \n
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.

1 participant