Repository navigation
Conversation
CodeMirror reads \r\n, \r and \n alike and hands its document back joined with \n. Save wrote that straight through, so editing one character of a Windows file in a picked folder rewrote every line ending on disk, and git showed the whole file as changed. AnnotateCode is supposed to leave code as it found it. The editor's normalising is what keeps positions and anchors simple, so it stays. Instead the file's dominant line break, read from the cached text the edit replaces, is put back in the adapter on the way out to disk and cache. A file that mixes endings is written with the one it used most: much closer than the all-\n rewrite, and keeping per-line endings through arbitrary edits is not worth the machinery for what is almost always an accident. Notebooks are left alone: what is edited there is the generated \n reading view, and the file on disk is rebuilt as JSON. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ewraj
added a commit
that referenced
this pull request
Oct 8, 2026
Committing a note closes its card at once, then saves the note, and the chip is drawn after the save. The test read the chips once, right after the card closed, so it sometimes found none: 8 failures in 40 runs on main. It also failed the rerun of #20 and one run on #22, neither of which touches notes. Polling waits for the save. 80 of 80 runs pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Foundation fix F10 from
PHASE_6_OVERVIEW.md(#17). This is a bug onmaintoday, independent of Phase 6.The bug
CodeMirror splits a document on
\r\n,\rand\n, anddoc.toString()always joins it back with\n.CodeViewhandsdoc.toString()to the session, andsavewrites it through the adapter. As a result, editing one character of a Windows (CRLF) file in a picked folder rewrites every line ending on disk, and the whole file shows as changed in version control.The fix
The editor keeps normalising to
\n, which is what keeps positions and anchors simple. The file's line break is restored at the one place text leaves for disk:src/sources/lineBreaks.ts:dominantLineBreak,withLineBreakandkeepLineBreaks.CachingAdapter.writeFileandStoredAdapter.writeFilere-apply the dominant break of the cached text the edit replaces. Both the disk and the cache get the same bytes, so the next save sees CRLF again.\nreading view, and the file on disk is rebuilt as JSON bysourceToNotebook.CachingAdapteris now exported so the save path can be tested directly.Known limit: a file that mixes endings is written with the one it uses most. That's much closer to the original than today's rewrite to all
\n. Keeping each line's own ending through arbitrary edits would mean mapping them through every change, which isn't worth it for what is almost always an accident.Tested
\n, and\r\ncounts as one break) and for conversion.EditorState→ save throughCachingAdapter: the bytes written to "disk" and to the cache are still CRLF. A second save keeps them. A Unix file stays Unix.autocrlf.npm run typecheck,npm test(283 tests),npm run buildandnpm run test:e2e(29 tests, Chromium) all pass locally.Not covered: an e2e test with a real picked folder. Playwright can't drive
showDirectoryPicker, and the existing suite seeds IndexedDB instead.🤖 Generated with Claude Code