Overwrite mode cursor

CodeMirror respects if the user has pressed the insert key to go into overwrite mode or not and even has a toggleOverwrite method - but the cursor doesn’t change.

What would be the best way to show the block cursor if in overwrite mode?

Was about to start work on implementing something and came across this in codemirror.css:

/* Can style cursor different in overwrite (non-insert) mode */
.CodeMirror-overwrite .CodeMirror-cursor {}

Which is great as I can implement styling here, but 3 quick thoughts:

  1. Could do with some style here? width: auto; border-left: 1px solid black; maybe?
  2. Could make mention of this class in the manual?
  3. I think the comment needs updating to be (insert) rather than (non-insert) mode?

Happy to raise a PR for 1 & 3 if you’d like?

I think “non-insert” makes sense in the comment—overwrite mode is the alternative to insert mode.

I’m not sure if there’s a default style that’s unproblematic for everyone. As the vim mode shows, displaying a fat cursor that actually aligns with the character after the cursor is tricky, and I’d rather not pull in that complexity for this use case. Coloring the cursor is heavily theme-dependent, so again, not a trivial change.

As such, I prefer to leave this to integrations. Mentioning the class in the manual would be a good idea.

1 Like

Totally understand re not having a style there and mentioning it in the manual would be enough. :+1:

Also, my bad - the comment is indeed right being (non-insert).