Skip to content

Exception when editor is initialized out of view #952

@lishid

Description

@lishid

Describe the issue

Seems that a recent commit introduced an exception when initializing an editor that's out of view due to display: none.

Commit in question: codemirror/view@4b6d0c9

Exception:

Uncaught TypeError: Cannot read properties of undefined (reading 'length')
    at TextNode.lineInner (index.js:221:64)
    at TextNode.line (index.js:23:21)
    at HeightMapGap.blockAt (index.js:4184:36)
    at HeightMapGap.lineAt (index.js:4189:25)
    at HeightMapBranch.lineAt (index.js:4290:26)
    at HeightMapBranch.lineAt (index.js:4290:26)
    at HeightMapBranch.lineAt (index.js:4290:26)
    at HeightMapBranch.lineAt (index.js:4290:26)
    at HeightMapBranch.lineAt (index.js:4290:26)
    at HeightMapBranch.lineAt (index.js:4290:26)
lineBlockAtHeight	@	index.js:4921
measure	@	index.js:6180

Specific debugging leads to a NaN here:
image

Then here:
image

Browser and platform

Windows Chrome

Reproduction link

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions