edit icon indicating copy to clipboard operation
edit copied to clipboard

Add Support for RTL Languages

Open baget opened this issue 7 months ago • 6 comments

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

Image Image

baget avatar May 19 '25 16:05 baget

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. 😢

lhecker avatar May 19 '25 16:05 lhecker

neatvi comes to mind as a small editor with proper RTL support.

firasuke avatar May 20 '25 17:05 firasuke

I found this https://github.com/servo/unicode-bidi maybe it can be used

baget avatar May 20 '25 17:05 baget

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.

Bip901 avatar Aug 03 '25 14:08 Bip901

Ok, so I guess, we can close this issue.

baget avatar Aug 03 '25 16:08 baget

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).

lhecker avatar Aug 04 '25 11:08 lhecker