Bizarre tab/diagnostic interaction

In my IDE, if a line starts with a tab character, then a word, and that line is marked as an error (including the tab) using diagnostics, and I put my cursor after the tab and press a key, the cursor first moves to the end of the line before inserting the character. This does not happen if the line does not start with tab, or is not marked as an error, or if the tab is not included in the error diagnostic! Also this behavior happens at the start of any word in the line, not just the one after the tab, but not in the middle of any word. I’ve tried removing all extensions I could, including any odd keymaps or tab-related ones.

You can try it here: TRS-80 IDE Insert a new line with tab, then “foo” (no quotes), then move off the line and back on (to trigger the diagnostic), put your cursor before “foo”, then press a letter.

I wanted to make a simple reproducible case for this, so I tried the “Try” editor, but I get the error “SyntaxError: The requested module ‘./mods/@codemirror-lint.js’ does not provide an export named ‘Diagnostic’”. (See link below).

Any idea how to demo this code in Try? Or other stuff I should check out to debug the actual problem?

Thank you!


Write JavaScript, not TypeScript. Diagnostic is a type, so you can’t import it without TypeScript.

It would also be useful to know which browser this happens in.

Thank you for pointing out the type import! I got the bug to reproduce, see below. It happens in Chrome on Mac. It does not happen in Firefox on Mac. Place your cursor at the beginning of either “foo” and type “x”, and the cursor will jump to the end of the line before inserting the “x”. The highlightSelectionMatches() plugin seems to be the culprit. I’ve not dug into it yet.

Note that setting highlightWordAroundCursor to false makes the bug go away. I just poked around the code of that plug-in and don’t see a way for it to update the selection, it only adds decoration. Are the two decorations (word highlight and error highlight) conflicting?

Would you like me to open a Github issue for this? Happy to do it.

This seems to be a Chrome bug. Can be reproduced with a very simple piece of HTML.

<div style="white-space: pre" contenteditable=true><span>	<span>foo</span></span></div>

Putting the cursor before foo and typing inserts content at the end of the line. I’ve opened an issue in the Chrome bug tracker.