microbit-foundation / python-editor-v3

Micro:bit Educational Foundation Python Editor V3
https://python.microbit.org
MIT License
57 stars 36 forks source link

[CodeMirror] Crash in drawSelection extension #1065

Open microbit-matt-hillsdon opened 1 year ago

microbit-matt-hillsdon commented 1 year ago

This one happened immediately on navigating to, but not opening, the Dice Idea.

I guess it's possible it is the read-only CM in the sidebar.

TypeError: Cannot read properties of null (reading 'top')
  at addSpan(../node_modules/@codemirror/view/dist/index.js:7415:39)
  at drawForLine(../node_modules/@codemirror/view/dist/index.js:7441:13)
  at measureRange(../node_modules/@codemirror/view/dist/index.js:7387:33)
  at ? (../node_modules/@codemirror/view/dist/index.js:7299:74)
  at Array.map(<anonymous>)
  at read(../node_modules/@codemirror/view/dist/index.js:7299:50)
  at ? (../node_modules/@codemirror/view/dist/index.js:6380:34)
  at Array.map(<anonymous>)
  at measure(../node_modules/@codemirror/view/dist/index.js:6378:42)
  at wrappedArguments(../node_modules/@codemirror/view/dist/index.js:6505:79)
  at i(../../../../browser/src/helpers.ts:73:23)

On the face of it none of our code is involved in this one.

The line in question seems to be something of a hack, it uses any in the TypeScript source to allow it to pass 2 or -2 as the side parameter. This seems to be a kind of internal API, 2/-2 are special cased even though they're not valid according to the parameter types.

Let's see if we can come up with a repro.

Chrome 107/Windows.