Add Support for RTL Languages
When editing RTL languages like Hebrew, the text appears in the incorrect order.
Additionally, when opening a text file containing Hebrew text, the content is displayed backward.
Expected behavior: The text should display correctly, e.g., שלום מיקרוסופט.
Compare with what Notepad is displaying
We can use vim -H (Hebrew-) and vim -A (Arabic-mode) as reference when implementing this. I'm not sure what the runtime / space cost of BiDi analysis is, so it may be possible we can equally only make it opt-in. It would be especially helpful if anyone who natively speaks an RTL language, or better yet knows BiDi algorithms already, could help out on this, because I'm no good with either. 😢
neatvi comes to mind as a small editor with proper RTL support.
I found this https://github.com/servo/unicode-bidi maybe it can be used
Hi, native Hebrew speaker here.
edit actually does exactly what it's supposed to: it outputs the stream of characters in the order they are written.
It is the Terminal's job to render them correctly. What you encounter here is a bug in Windows Terminal. If you open the same file using edit on Gnome Terminal, Terminator, or any other modern terminal, you'd see the characters in the correct order. There's an open issue about it here: https://github.com/microsoft/terminal/issues/538
Of course, those terminals' behavior, while helping a little, is still unsatisfactory- they choose a direction based on the beginning of the line's content, and then they print the entire line in that direction. That's naive because lines may contain words in mixed languages. In that case, some support from edit may be required to communicate instructions to the terminal. But this remains an unsolved issue which goes much deeper than just edit.
Ok, so I guess, we can close this issue.
I believe BiDi is a different topic from supporting RTL at all. Although I'll untag this as "Help Wanted" because I realize now that it's too early to support something like this. RTL in terminals is a somewhat annoying problem, and I'd like to focus us on supporting editing machine readable text first (e.g. JSON, programming languages, etc., which are all primarily English).