Files
orca/docs/site/content
Neil c097acc64e fix(editor): new files use the owning host's line ending; add End of Line setting (#43253)
* fix(editor): give new files the owning host's line ending, add End of Line setting

A file with no line breaks yet took the ending of the OS the window runs on,
so a Windows client wrote CRLF into files on WSL hosts and Linux SSH hosts.
Such models now adopt the ending of the host that owns the file (LF on Linux
and macOS, CRLF on native Windows), and Settings > General > Editor gains an
End of Line choice (Auto, LF, CRLF). Files with line breaks keep theirs.

Fixes #43216

* fix(editor): resolve paired-host files by endpoint and keep new-file EOL through undo

- Resolve a file's host from its endpoint-relative authority, so a file on a
  WSL host or paired server reads that host's OS instead of this client's.
- Only a WSL host's own files fall back to Linux; SSH targets behind it do not.
- Track whether a model was loaded with line breaks, and keep a new model on
  its chosen ending through undo, late host reports, and setting changes.
- A model without line breaks adopts the ending of external text written in.
- Read remote OS facts directly so the selector builds no translated strings.
- Docs describe Auto by where the workspace runs (Windows projects in WSL get LF).

* fix(editor): keep undo valid across late EOL conversion; respect text written while unmounted

- Convert typed lines with an undoable pushEOL step instead of a bare setEOL,
  whose stale offsets corrupted Undo. Only a new choice (late host report or
  setting change) converts multiline text, so Undo of the conversion sticks.
- Record outside text with line breaks on the model from the content-sync
  paths, so a remounted editor never converts text the user did not type.

* fix(editor): never convert a new file's line endings once its lines are saved

A clean buffer with line breaks matches the file on disk, so it is treated as
an existing file: changing End of Line later no longer converts it, marks it
dirty, and lets autosave rewrite it. Only typed, unsaved lines are converted.

* fix(editor): treat a new file as saved only when its bytes match disk

The dirty flag ignores Markdown trailing whitespace, so a clean flag did not
prove typed line breaks were saved. Compare the model text with the buffer's
last known disk signature instead. Also type the line-ending state by its
model shape for the anti-slop lint, localize the LF/CRLF labels, and note in
the docs that autosaved lines keep their ending if the host reports later.

* fix(editor): only set a new file's line ending while it has at most one line

Converting text that already has line breaks kept running into cases where
saved or in-flight lines were rewritten. The editor now sets the ending only
while the model has at most one line, at mount and whenever the choice
changes, and re-applies it when Undo returns to one line. Text with line
breaks is never converted. This removes the multi-line conversion, its undo
step, the per-model state and the disk-signature check.

* fix(editor): keep an existing file's line ending after it is emptied

A model that already had line breaks when the editor mounted, or got them
from a programmatic or outside write, is flagged as an existing file and
never has its ending set again, so emptying and retyping it keeps the file's
ending. Line breaks the user typed do not set the flag, so Undo back to one
line still restores the chosen ending. Scope the docs sentence on outside text.

* fix(editor): carry a buffer's line ending through model rekeys and renames

A replacement model was built from text and language alone, so an emptied
or one-line existing file lost its ending and existing-file status. The rekey
carry now copies both to the model it creates. A rename remounts the editor
under a new view id, so the rename records the old model and the remount
carries an unsaved draft the same way. Existing models at the destination are
never touched.

* fix(editor): hand a renamed buffer's line ending over as a snapshot

The rename handoff stored the old model's address, which model cleanup could
dispose before the renamed tab mounted, and records were never cleared. The
rename now snapshots { ending, existing-file } from the old model, only for a
tab with an unsaved draft, keyed by the new tab id. The tab-close cleanup
drops it, and the remount applies it only to the model it builds from the
draft. Same-view re-keys still carry from the live model.
2026-11-16 14:49:08 -08:00
..