[Bug]: Files surface jumps scroll focus and throws "Line doesn't exist" with word wrapping activated #7907
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/web
Steps to reproduce#
- Have "word wrap" activated in settings>apperance> word wrap at bottom
- Open a file with files surface in the right sidebar (with a lot of collapsable lines, less width => more lines collapsed)
- Add more lines
- Watch weird behavior with focus - Spamming enter will cause throwing an error
--- CLANKER DIAGNOSTIC BELOW (untested and personally not convinced at first glance, it could be a pierre/diffs issue) ---
The bug is a stale height calculation in the virtualized editor in t3code>apps>web>src>components>files>FilePreviewPanel.tsx.
When wordWrap is enabled:
- A logical line can occupy several visual rows, especially at narrow widths.
- Pressing Enter invalidates the virtualizer’s cached line heights.
- Before the wrapped lines are measured again, the editor tries to reveal the caret and restore scroll.
- It estimates positions using the default one-row
lineHeight. - That estimate is too small, so the scroll jumps upward. The virtualizer may also recycle the focused DOM row, making the caret appear to disappear.
At wide widths, lines barely wrap, so the estimate is close enough and the bug is hidden. Disabling wrapping removes the variable-height layout entirely, which is why the problem disappears.
Short version: Enter exposes a race between editing, caret scrolling, and remeasuring wrapped virtualized lines.
Expected behavior#
Adding a line in a files surface should not mess up with focus and no error should be threw
Actual behavior#
Adding a line in a surface with a lot of wrapped lines will cause focus jumps and eventually it will cause throwing an error
Impact#
Minor bug or occasional failure
Version or commit#
0.0.34-nightly.20260820.1142
Environment#
CachyOS, desktop app
Logs or stack traces#
FileRenderer.processFileResult: Line doesnt exist
Error: FileRenderer.processFileResult: Line doesnt exist
at be.processFileResult (t3code://app/assets/DiffCommentAnnotation-DQOJaIPV.js:1:7801)
at be.renderFile (t3code://app/assets/DiffCommentAnnotation-DQOJaIPV.js:1:18824)
at je.renderPreparedFile (t3code://app/assets/DiffCommentAnnotation-DQOJaIPV.js:1:41228)
at je.renderPreparedFile (t3code://app/assets/DiffCommentAnnotation-DQOJaIPV.js:1:17214)
at je.onRender (t3code://app/assets/DiffCommentAnnotation-DQOJaIPV.js:1:35788)
at computeRenderRangeAndEmit (t3code://app/assets/index-DzSq6vN-.js:1886:73302)
at fm (t3code://app/assets/index-DzSq6vN-.js:306:14489)
Screenshots, recordings, or supporting files#
Workaround#
No response
fgonzalezurriola(GitHub profile, opens in a new tab) added labelsbug
fgonzalezurriola(GitHub profile, opens in a new tab) added labelsneeds-triage
September 5 audit update: #10018 merged into main at 6270a6f8. It fixes the loss of unchanged wrapped-row measurements during edits and invalidates obsolete measurements when the editor width changes.
In the matched Linux Chromium test, the first Enter in an 8,255-line wrapped file now keeps the new EOF line and caret visible. Native resize controls passed in both directions, along with 55 focused tests. The PR includes before/after recordings.
This issue stays open. Redo and caret scrolling after resize or a line-number digit boundary can still jump; this fix does not change that behavior. The original CachyOS/Electron environment was not exercised. A retest on current main with a shareable sample file and exact remaining action would help narrow those symptoms.
GPT 6 Astra via Codex in T3 Code.
Reproduced remaining jumps on current main (
dc39615ae), macOS 15.7.5, Chromium 151 web client; desktop/Electron was not used.Offsets below are CSS pixels;
Lis the native shadow-DOM selection line. Editor height: 708 px; narrow width: 419 px.Scenario Action scrollTop / caret before → after Result A Enter ×15, type end52108/L1190 → 52400/L1205 Visible, 2/2 B Cmd+Z ×8 52400/L1205 → 52268/L1198 Visible B First Cmd+Shift+Z 52268/L1198 → 40008/L1001 Jump, 2/2 B Finish eight redos 40008/L1001 → 62400/L1205 EOF restored C Divider: 619→419→663 px 47728/L600 → 34608/L951 → 29408/L951 Caret offscreen; 1/3 trials failed C Viewport: 1280→1080→1480 px 17728/L600 → 23648/L600 → 20728/L600 Visible throughout D Enter: 999→1000 lines 49188/L999 → 29308/L801 Caret offscreen, 2/2 D Three more Enters 29308/L801 → 49260/L1003 EOF restored E Enter ×10: 1190→1200 52108/L1190 → 52300/L1200 Visible Reproduce
- Download wrap-sample.txt and wrap-sample-999.txt into a project. Each line is 240 characters; neither file has a trailing newline.
- Enable Settings → Appearance → Word wrap. At 1280×800, open the Files surface, hide its explorer, and narrow the editor to about 419 px.
- Open the fresh 999-line sample, click into the editor, Cmd+End, then Enter once. The first visible line jumps 994→828; the caret stays offscreen after another 700 ms. Three more Enters restore EOF.
- Separately, with the fresh 1190-line sample: Cmd+End, Enter ×15 (~120 ms apart), type
end, Cmd+Z ×8 (~150 ms apart), then Cmd+Shift+Z once. The view jumps 1186→1001 and stays there until the next redo.
For resize, I scrolled to and clicked line 600 before dragging. The first trial jumped to visible line 1081; two retries passed. Widening was layout-clamped to 663 px. Browser viewport resizing passed.
No
Line doesnt exist/Line doesn't existerror or page errors occurred during these scenarios.
juliusmarminge added labelsneeds more info
juliusmarminge removed labelsneeds more info
This is the same problem as #33627, so I'm closing it in favour of that one. If it is different, say how and it will be reopened.
juliusmarminge closed this
Sign in to join this conversation.
The September 4, 2026 audit found and fixed a separate file-save lifecycle bug in #9878, now on main at b01771c2. React development effect replay had disposed the save coordinator, so real editor changes never reached disk. The PR contains before/after recordings and focused regression tests.
On Linux Chromium 152, the corrected code persisted native typing, a Markdown checkbox, and 60 Enter presses in a wrapped-line control through close/reopen, with no captured browser errors. That smaller control does not establish a fix for this report's larger wrapped-file focus jumps or
Line doesnt existerror in the CachyOS desktop app. This issue remains open. A current-version desktop retest with a shareable sample file would help reproduce that exact path.GPT 6 Astra via Codex in T3 Code.