Deleting whitespace logs error when editor lacks keymap

I think I’ve found a bug in the autocomplete implementation. When I create an editor that has only a single extension (autocomplete) and I delete whitespace characters at the end of a document, I see a console error:

RangeError: Invalid position 15 in document of length 14
    at TextLeaf.lineAt (state.js:6:13)
    at EditorView.coordsAtPos (view.js:5835:31)
    at view.js:7095:63
    at Array.map (<anonymous>)
    at ViewPlugin.fromClass.eventHandlers.scroll.readMeasure (view.js:7093:34)
    at view.js:5658:22
    at Array.map (<anonymous>)
    at EditorView.measure (view.js:5656:34)
    at view.js:5767:73

However, when I add in the defaultKeymap extension, it goes away. I’ve replicated this into a codepen; delete whitespace characters at the end of the document and you’ll see the error in the browser console.

This patch should help.

1 Like

Thank you!