Skip to content

Fix line offsets when incremental edits join CRLF - #1882

Open
ammann (agammann) wants to merge 1 commit into
microsoft:mainfrom
agammann:fix-crlf-incremental-line-offsets
Open

ammann (agammann) wants to merge 1 commit into
microsoft:mainfrom
agammann:fix-crlf-incremental-line-offsets

Conversation

@agammann

Copy link
Copy Markdown

Bug

An incremental edit can join a carriage return and line feed across the edit boundary while leaving the cached line offsets stale. For example, inserting \n at line 1, character 0 in a\rb produces a\r\nb, but lineCount returns 3 instead of 2. Line and position lookups then disagree with a fresh document containing the same text.

Fix

Invalidate cached line offsets when an edit leaves a CRLF pair across either edit boundary. The next lookup rebuilds them from the updated content; other edits retain the incremental update path.

Verification

  • The new regression failed on unmodified b4f995b (3 !== 2) and passes with this fix. It covers insertion at either side of the boundary, removal of an intervening character, and a batch of edits.
  • textDocument: npm run all (63 tests passing).
  • Repository: npm run symlink, npm run compile, npm run lint, and npm test passed locally on Node 22.
  • On this Ubuntu 26.04 host, Playwright's browser suites used its Ubuntu 24.04 Chromium build via PLAYWRIGHT_HOST_PLATFORM_OVERRIDE=ubuntu24.04-x64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant