Skip to content

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

Merged
CalvinAllen merged 1 commit into
CodingWithCalvin:mainfrom
Gh61:fix/tools/normalize-line-endings
Jun 16, 2026
Merged

fix(tools): normalize line endings on document write and replace #93
CalvinAllen merged 1 commit into
CodingWithCalvin:mainfrom
Gh61:fix/tools/normalize-line-endings

Conversation

@Gh61

@Gh61 Gh61 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

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

@CalvinAllen CalvinAllen changed the title fix(tools): normalize line endings on document write and replace operations fix(tools): normalize line endings on document write and replace Jun 15, 2026
@CalvinAllen

Copy link
Copy Markdown
Contributor

@Gh61 Ah, nice find!

@CalvinAllen

Copy link
Copy Markdown
Contributor

@Gh61 The build failed but wasn't anything on your PR - a NuGet dependency is being flagged because of a vulnerability. I'll take a look at that separately and then we can check this again.

…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
@CalvinAllen CalvinAllen force-pushed the fix/tools/normalize-line-endings branch from 804bd34 to 770d28e Compare June 16, 2026 19:21
@CalvinAllen CalvinAllen merged commit 663c876 into CodingWithCalvin:main Jun 16, 2026
2 checks passed
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.

2 participants