codemirror / codemirror5

In-browser code editor (version 5, legacy)
http://codemirror.net/5/
MIT License
26.84k stars 4.97k forks source link

cursor not shown around collapsed code in contenteditable inputStyle #4801

Open dwelle opened 7 years ago

dwelle commented 7 years ago

In contenteditable inputStyle, I noticed several cursor bugs when moving cursor around folded code (created via markText() with default options):

  1. the cursor is not visible when it's right to the left of the marker

code_fold_cursor

  1. if the character after the marker is EOL (\n), cursor is not visible when moved after the marker, as well. Also, this case makes the cursor visibly stay at previous position even if it's already after the marker (e.g. when changing position via click) until after you write a character, see image below:

code_fold_cursor_2

  1. (not reproducible 100% of the time) when the marker is preceded by whitespace-only the cursor cannot be moved to the beginning of the line by moving it down/up from next/previous line via arrow key

None of this is reproducible in textarea. CM version 5.26.0, win7

adrianheine commented 7 years ago

Thanks for your report. Maybe there is an easy fix for this, but it's quite difficult to reliably position the cursor in contenteditable inputStyle in general, so I don't want to spend time looking into it. The code we currently use definitely has issues and for example doesn't work well with bidirectional content.

dwelle commented 7 years ago

@adrianheine yea, I guess it's just another point in the tally against defaulting to contenteditable in the future

adrianheine commented 6 years ago

Actually, we are indeed working on a rewrite (CodeMirror 6) that will only support contenteditable. However, integration will be much better and we are planning to put a lot of work into issues like these. We are currently raising money for this work: See the announcement for more information about the rewrite and a demo.

Note that CodeMirror 6 is by no means stable or usable in production, yet. It is highly unlikely that we pick up this issue for CodeMirror 5, though.