InlineCoordsScan.scan can cause RangeError: Maximum call stack size exceeded #1699

Closed
opened 2026-04-28 09:23:16 +02:00 by craftzdog · 5 comments

Since @codemirror/view@6.41.0, it randomly causes an error when moving the cursor vertically with j/k keys with the vim extension.
A workaround is to downgrade it to v6.40.0.
It looks like it's introduced by commit 49d72c4.
I think it's not a bug of @replit/codemirror-vim, so I report it here.

Stack trace

index.js:1358 RangeError: Maximum call stack size exceeded
    at InlineCoordsScan.scan (index.js:3834:1)
    at InlineCoordsScan.scan (index.js:3914:1)
    at InlineCoordsScan.scan (index.js:3918:1)
    at InlineCoordsScan.scan (index.js:3914:1)
    at InlineCoordsScan.scan (index.js:3918:1)
    at InlineCoordsScan.scan (index.js:3914:1)
    at InlineCoordsScan.scan (index.js:3918:1)
    at InlineCoordsScan.scan (index.js:3914:1)
    at InlineCoordsScan.scan (index.js:3918:1)
    at InlineCoordsScan.scan (index.js:3914:1)
    ...

How to reproduce

  • Use the vim extension
  • Load a document with mixed-height inline content (e.g. a 200% heading next to normal text)
  • Call view.posAtCoords({x, y}, false, 1) with a y that overlaps both neighbors
Since @codemirror/view@6.41.0, it randomly causes an error when moving the cursor vertically with `j/k` keys with [the vim extension](https://github.com/replit/codemirror-vim). A workaround is to downgrade it to v6.40.0. It looks like it's introduced by commit [49d72c4](https://code.haverbeke.berlin/codemirror/view/commit/49d72c4). I think it's not a bug of `@replit/codemirror-vim`, so I report it here. ## Stack trace ``` index.js:1358 RangeError: Maximum call stack size exceeded at InlineCoordsScan.scan (index.js:3834:1) at InlineCoordsScan.scan (index.js:3914:1) at InlineCoordsScan.scan (index.js:3918:1) at InlineCoordsScan.scan (index.js:3914:1) at InlineCoordsScan.scan (index.js:3918:1) at InlineCoordsScan.scan (index.js:3914:1) at InlineCoordsScan.scan (index.js:3918:1) at InlineCoordsScan.scan (index.js:3914:1) at InlineCoordsScan.scan (index.js:3918:1) at InlineCoordsScan.scan (index.js:3914:1) ... ``` ## How to reproduce - Use the vim extension - Load a document with mixed-height inline content (e.g. a 200% heading next to normal text) - Call `view.posAtCoords({x, y}, false, 1)` with a `y` that overlaps both neighbors
Owner

I didn't manage to reproduce this, even when intentionally making elements overlap with a low line-height. Also, your reproduction instructions don't seem to use the vim extension, yet say to load it. It would be helpful if you could set up a small self-contained demo for this. And also let me know which browser(s) you can reproduce it in.

I didn't manage to reproduce this, even when intentionally making elements overlap with a low line-height. Also, your reproduction instructions don't seem to use the vim extension, yet say to load it. It would be helpful if you could set up a small self-contained demo for this. And also let me know which browser(s) you can reproduce it in.
Author

Now I can't even reproduce it on my Electron app 🤯
I use electron@39.8.7.
Sorry, I will try to investigate further when this happens again.

Now I can't even reproduce it on my Electron app 🤯 I use `electron@39.8.7`. Sorry, I will try to investigate further when this happens again.
Owner

I went ahead and added a safeguard for this, though I didn't manage to actually reproduce the issue.

I went ahead and added a safeguard for this, though I didn't manage to actually reproduce the issue.
Author

Wow thank you!
btw, a link in the email notification about the commit seems to be broken: https://code.haverbeke.berlin/codemirror/dev/commit/92bf92375cc1e174c2e5157ad5cd6f7bdb0296ca

@marijn closed #1699 in commit 92bf92375c.

It points to the codemirror/dev repo

Wow thank you! btw, a link in the email notification about the commit seems to be broken: <https://code.haverbeke.berlin/codemirror/dev/commit/92bf92375cc1e174c2e5157ad5cd6f7bdb0296ca> > **@marijn** closed [#1699](https://code.haverbeke.berlin/codemirror/dev/issues/1699) in commit [**92bf92375c**](https://code.haverbeke.berlin/codemirror/dev/commit/92bf92375cc1e174c2e5157ad5cd6f7bdb0296ca). It points to the `codemirror/dev` repo
Owner

That appears to be a Forgejo bug. I've filed https://codeberg.org/forgejo/forgejo/issues/12367

That appears to be a Forgejo bug. I've filed https://codeberg.org/forgejo/forgejo/issues/12367
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/dev#1699
No description provided.