Skip to content

[Bug]: Files surface jumps scroll focus and throws "Line doesn't exist" with word wrapping activated #7907

Description

@fgonzalezurriola

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

  1. Have "word wrap" activated in settings>apperance> word wrap at bottom
  2. Open a file with files surface in the right sidebar (with a lot of collapsable lines, less width => more lines collapsed)
  3. Add more lines
  4. 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:

  1. A logical line can occupy several visual rows, especially at narrow widths.
  2. Pressing Enter invalidates the virtualizer’s cached line heights.
  3. Before the wrapped lines are measured again, the editor tries to reveal the caret and restore scroll.
  4. It estimates positions using the default one-row lineHeight.
  5. 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

2026-08-22_10-19-13.mp4

Workaround

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.needs-triageIssue needs maintainer review and initial categorization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions