Skip to content

[Bug] Error when hovering over invalid :nth-child instruction #510

Description

@HoferMarkus

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.55.1#XQAAAAJqAQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscwzX_uRgmSaumWUF-TBOsVJ4S4FwfCDQb5-2uUHXTVAefbVSd9IzaZ_vv9VR9KugsKimARHSWlrTPOQHROITHxmAfWyxxqJxKmhw1cKTUXC0tx2LpbUNTPmPakHwRDCMzdoAiklOMc0p3Nr1fBa5SNIwkn6xD0gCTG5vcEJD-YrwETkeoWK28F2pb0Xq2fx4k1Ro7TuHxRZ1iSvU7MtPNYGKzp0ebj-RR9nalP9jmhdCOn5j5ER-RZjhXLtDzaRkrurbfokzAEOcnE5RBpV-y-cxtaDh4MvXt4BxzTpLB0fRna43Wbadj-9N5-_A

Monaco Editor Playground Code

:nth-child()

Reproduction Steps

  • Create Monaco editor instance with CSS language
  • Write an invalid nth-child selector, e.g. just a plain :nth-child()
  • Hover over the nth-child text

Actual (Problematic) Behavior

Editor throws with:

TypeError: Cannot read properties of undefined (reading 'getText')
at r (css.worker-HnVq6Ewq.js:50:3825)
at r (css.worker-HnVq6Ewq.js:50:4197)
at Fm.selectorToSpecificityMarkedString (css.worker-HnVq6Ewq.js:50:4254)
at Fm.selectorToMarkedString (css.worker-HnVq6Ewq.js:50:2263)
at ps.doHover (css.worker-HnVq6Ewq.js:50:6293)
at _f.doHover (css.worker-HnVq6Ewq.js:93:10456)
at Rt.$fmr (css.worker-HnVq6Ewq.js:26:15794)
at Gh._handleMessage (css.worker-HnVq6Ewq.js:7:36565)
at Object.handleMessage (css.worker-HnVq6Ewq.js:7:36059)
at Hh._handleRequestMessage (css.worker-HnVq6Ewq.js:7:34816)
at r (css.worker-HnVq6Ewq.js:50:3825)
at r (css.worker-HnVq6Ewq.js:50:4197)
at Fm.selectorToSpecificityMarkedString (css.worker-HnVq6Ewq.js:50:4254)
at Fm.selectorToMarkedString (css.worker-HnVq6Ewq.js:50:2263)
at ps.doHover (css.worker-HnVq6Ewq.js:50:6293)
at _f.doHover (css.worker-HnVq6Ewq.js:93:10456)
at Rt.$fmr (css.worker-HnVq6Ewq.js:26:15794)
at Gh._handleMessage (css.worker-HnVq6Ewq.js:7:36565)
at Object.handleMessage (css.worker-HnVq6Ewq.js:7:36059)
at Hh._handleRequestMessage (css.worker-HnVq6Ewq.js:7:34816)
at editor.api-CalNCsUg.js:3:12

In the PG the error is shown in console.
In my real world application the editor instance actually throws, triggering the app-specific error handling (generic error dialog, etc..)

Expected Behavior

No response

Additional Context

No response

Activity

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

Metadata

Metadata

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