Open dannaf opened 2 days ago
Hey @dannaf,
As far as I'm aware, monaco editor doesn't support RTL languages. Can you try whether this works in VS Code? If it doesn't, please file an issue with them.
Aw, that's an upsetting surprise; you are correct, as noted here: https://github.com/microsoft/monaco-editor/issues/2371#issuecomment-1459973407. I'll try to reopen that discussion there sometime hopefully.
But, as for Theia, I tried it now with VS Code and it actually did work better than in Theia. When I pasted the testing sentence that I suggested above it appeared fine:
However, when I typed it the behavior was a bit strange; a bit strange but usable, and it ended up fine at the end of the sentence. What seems to occur is that when typing RTL the cursor position is fine intra-word (i.e. on the left) but upon every spacebar it teleports to the full-right (instead of moving one spacebar-worth further to the left) but it thereafter teleports back to the full-left when starting to type the next word. The same thing happens during the parentheses, except that with the automatic placement of the closing parentheses in the editor upon opening the first parentheses it looks a bit more strange as there is a closing parenthesis hanging out to the right of the sentence. But this goes away when typing the close of the parenthesis, at which point the right-dangling parenthesis teleports to the left where it should be and that ordeal gets wrapped up.
This inconvenience in VS Code is not ideal, but I would say that it is essentially usable for a flexible user who can ignore the junk happening at the right like the cursor and the parenthesis hanging out there, and focus on writing beautifully into the sunset—I mean, writing onwards to the left -:) Whereas the current situation in Theia I characterize as unusable, because any use of parentheses demolishes the entire line by chopping it into parts and then scrambling them up.
Bug Description:
When typing in a right-to-left language in the Editor, word sequence order is not maintained properly when parentheses are used. (I observed this bug with Hebrew, specifically, but presumably it may affect right-to-left languages generally.)
Steps to Reproduce:
testing.md
and open it in the Theia Editor.To make sure the visual sequence is clear, here is a screenshot of how the sentence is supposed to look (a screenshot of the codeblock text above, which is correct):
which in my current/default font in the Theia Editor should look like:
But here is how it appears in the Theia Editor for me:
Notice how the three parts are reversed. Each part is internally in the correct word order (and each word is in the correct character order), but the sequence of these parts is reversed.
Note also that the problem arises as soon as the first parenthesis is typed, which already appears in the wrong place (as though it is at the current cursor position in a left-to-right sentence, i.e. at the right, instead of appearing at the proper cursor position for a right-to-left sentence, i.e. at the left). This makes the Theia Editor almost unusable for typing prose in Hebrew, as any use of parentheses completely throws off the entire line (which should be able to accommodate even a whole paragraph).
Moreover, it is then difficult to correct the problem after typing the text with the parentheses (even if the user may want to add linebreaks before and after the parentheses to alleviate this) as the Editor graphics are then desynchronized with the actual cursor position, i.e. clicking or using the arrow keys becomes very confusing; adding line breaks becomes a guessing game of trial and error. To best see this, which may even be a separate bug, click on the left-most Hebrew character that's to the right of the left parenthesis, in the sentence as it appears in the incorrect order when pasted with the current bug, as shown non-selected in the following screenshot (it is not selected precisely due to the issue that is being described here, that there is a cursor issue when trying to target that character)
and observe the Editor cursor appear at a different location than where the user clicked, namely to the right of the right-most character that's to the left of the right parenthesis, just-left of the right parenthesis, as shown in the next screenshot:
Additional Information