codemirror / codemirror5

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

Issue with `unicode-bidi: isolate` use #4532

Open ebraminio opened 7 years ago

ebraminio commented 7 years ago

Steps to repro:

  1. Open http://codemirror.net/mode/python/index.html and put this code print('\n'.join(['متن متن', '123']))
  2. Add this CSS .cm-string { unicode-bidi: isolate; unicode-bidi: -webkit-isolate; } to your browser CSSs
  3. Try to highlight first word on array by double clicking

Actual: You can select the first word. While step 2, fixes the visual issue I've describe here, it breaks the editing experiencing I've described here

Expected: That CM won't care about unicode-bidi state, or even better, the CSS mentioned above be added to CM CSSs to help issues like this, in addition to fixing the issue with isolate bidi.

marijnh commented 7 years ago

CodeMirror computes the order of bidi text independently from the browser, for the purpose of cursor motion and drawing the selection. Styling pieces of content with non-default unicode-bidi values will unfortunately put this computation out of sync, and produce the issue you describe.

It is not clear to me what we could do about that (getting the computed style for each token and somehow taking that into account when computing the bidi ranges would be too expensive and complicated).

ebraminio commented 7 years ago

Do you see any other way for CM be able to implement someway for isolating bidi of cm-string and/or any other chosen elements? If so the improvement can help many different project. For example on Chrome DevTools, this is correct while viewing:

screen shot 2017-02-02 at 4 08 50 pm

(which here is its related patch)

but incorrect on editing, which uses CM:

screen shot 2017-02-02 at 4 06 05 pm

(original testcase is <h1 title="متن">متن</h1> which is also broken on plain text but I hope we could do better on CM)

marijnh commented 7 years ago

It'd be possible to implement something like this, but I don't currently have the time to work on it, and as I mentioned, it'd be complicated (the bidi code is already quite scary).

ebraminio commented 7 years ago

No problem. Just wanted to know about the possibility. Thanks.

adrianheine commented 6 years ago

I think this is related to #4006.

ebraminio commented 6 years ago

I think also that can be resolved if unicode-bidi is taken into consideration.