When editing code it may be useful to show Arabic/Hebrew chars left to right. Any ideas how I could do that? I tried .CodeMirror-line{unicode-bidi:bidi-override}
in CSS. That made all text display as ltr but cursor movement still followed bidi rules. I tried to fix that with .setOption('rtlMoveVisually',1)
but it was still wrong near the start of the (normally rtl but now reversed) Arabic/Hebrew text.
If I end up doing this in CodeMirror’s code, would there be interest in merging it upstream?
Maybe you want to set "rtlMoveVisually"
to false
? 1
is still truthy.
er… ok, false
. I still find all this stuff confusing, sorry. So, with false
there’s this problem: suppose I have a few rtl characters, let’s call them ABCD for the sake of argument. I can’t go to the left of A - that location is simply skipped in cursor movement. When I go immediately to the right of A, two cursors appear - a faint one after A and a solid one before D. Backspace deletes the wrong characters and selection doesn’t work at all.
What I want to achieve is treat rtl characters as if they are ltr.
To clarify: I still have unicode-bidi:bidi-override in CSS, so ABCD appear in that order, left to right
This is what consecutive presses of right arrow result in:
Ah, I see what you mean. Cursor drawing will still assume that the characters are ordered RTL, and thus look wrong. I guess it would be possible to add an option that forces bidi-override
and disables all bidi-related cleverness. But is editing RTL text LTR something that people actually do and enjoy?
Generally not, but in programming it may be desirable.
I use CodeMirror to implement a REPL, which can optionally pretty-print data structures with line-drawing characters (I hope they render properly here):
┌───┬──┐
│ABC│DE│
└───┴──┘
If I try to print rtl strings I get something like
┌───┬──┐
│ED│CBA│
└───┴──┘
because the vertical line in the middle is bidi-neutral - it assumes the direction of the surrounding characters, so the whole line is reversed instead of the individual boxes. I realise that changing direction would make it hard for speakers of Arabic and Hebrew to read the text, but it seems to be the less painful option.
That seems a rather obscure (though indeed annoying) use case. I’m open to adding a feature like this at some point in the future, but I don’t have time to work on it right now.