amazon-q-developer-cli icon indicating copy to clipboard operation
amazon-q-developer-cli copied to clipboard

Support CRLF detection in WSL

Open brandonskiser opened this issue 1 year ago • 2 comments

Files on Windows use \r\n as the line ending whereas POSIX systems use \n.

This poses a problem when editing Windows files from WSL - in the fs_read tool, we only send the content joined by \n. This causes context-mismatch issues with the model whenever it attempts to make changes, since it is not expecting line endings to contain a \r prefix.

Instead, we should detect what line endings to use (\r\n vs \n) when editing a file since it is possible to edit Windows based files that use \r\n while in WSL.

brandonskiser avatar May 09 '25 16:05 brandonskiser

This is a great opportunity to enhance cross-platform compatibility. I'd be happy to investigate implementing a line ending detection mechanism. The approach could involve:

  1. Detecting the existing line ending style in the file (\r\n vs \n)
  2. Preserving that style when writing back changes via fs_write
  3. Adding tests for both Windows and POSIX line ending scenarios

Would this align with the expected solution? I can start working on a PR if this direction makes sense.

Scarmonit avatar Oct 30 '25 02:10 Scarmonit

I’m investigating a focused fix that preserves each file’s existing LF/CRLF style at the shared read/write boundary, with regression coverage for both endings. I found no linked implementation PR; I’ll keep the change scoped to this issue.

voidstackloop avatar Sep 13 '26 09:09 voidstackloop