[Bug]: Files surface jumps scroll focus and throws "Line doesn't exist" with word wrapping activated
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 23k
- Forks
- 5.9k
- Avg merge
- 11h 14m
- Merged PRs (30d)
- 357
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in apps/web/src/components/files/FilePreviewPanel.tsx and reproduce the issue with word wrap enabled, a narrow files surface, many collapsible lines, and repeated Enter presses. Use the reported “FileRenderer.processFileResult: Line doesnt exist” stack trace to trace the focus and scroll behavior. Done means adding lines preserves focus and does not produce the error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100