-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support RTL languages #701
Comments
It is actually a whole lot more complicated and includes statefulness and even mirroring certain characters. I'd say it's a science of its own. (And I have the deepest respect for those people who wrote robust text rendering libraries that handle all the BiDi issues properly, so I don't have to mess around with it, to be honest.) See also: EDIT: I think the way the new selection works may actually be unexpected because it is going to behave differently than VSCode itself. For example, given the text "The song מדינת קומבינה makes me think", when I start selecting at "The" and end between the two Hebrew words, I will have selected "The song מדינת", while in the console I will have selected "The song קומבינה". However it will still be better than how Sublime Text "works" last time I checked, because there you will see one thing selected but copy another, which is very annoying. |
@Tyriar Correct format: نادان Terminal: ن ا د ا ن Now your questions: How are the characters meant to interact with characters like 0-9 or punctuation? P.S 1: P.S 2: P.S 3: P.S 4: |
After Updating my vscode, Everything reversed, That is Very bad, Please Solve This problem |
@mostafa69d luckily enough in Hebrew that barely exist. Hebrew letters stay mostly the same in any position inside a word, besides few letters which are כ which turns to ך, then מ which turns to ם, then נ which turns to ן, then פ which turns to ף and finally צ which turns to ץ. This makes Hebrew easier to format, I guess. |
However these are still separate characters (in terms of character encoding) and always display the same. They do not change appearance when moved around. (It's the writer's job to use the right letter - sofit or not - at the right position.) |
required reading: https://opensource.com/life/16/3/twisted-road-right-left-language-support from microsoft/vscode#28571 (comment)
mlterm seems to be better than the average (non-web based) terminal. |
The character joiner API might be able to solve this, we could probably make all adjacent arabic/hebrew/etc. unicode characters join and be drawn in the same glyph. |
@babakks Only two Terminals as far as I know in the Linux system can output RTL correctly, |
@elieobeid7 @babakks Mac OS terminal output RTL correctly |
Put out a PR to fix this, if anyone wants to test out the branch that would be useful as I don't speak these languages. #1899 To test: git clone https://github.com/Tyriar/xterm.js
cd xterm.js
git checkout 701_rtl_support
yarn
yarn watch
# another terminals
yarn start You may need some dependencies to be installed https://github.com/Microsoft/node-pty#dependencies |
Please hold off for a little bit :) I've been recently working on studying, evaluating existing docs and implementations of RTL in terminals, and come up with a (draft) recommendation. I'll release it real soon now. It's way more complicated than one would first think. A bit of spoiler: If you start shuffling the characters around according to the BiDi algorithm, it becomes literally, mathematicaly provably impossible to have proper BiDi-aware text editing-viewing experience (e.g. vim, emacs...) on top of that platform. (And to respond to the previous few comments: no, konsole, mlterm and macOS Terminal don't get it right either.) |
@egmontkob does this take into account the fact that we get to leverage the browser's bidi support? All my change does is force related unicode sequences to be drawn together not as separate characters. This is probably wrong when the cursor is over the character but it seems to work other than that. |
@Tyriar Sorry Tyriar, but it's still wrong. I commented under the pull request. |
The spec defines how the canvas needs to look like, after receiving some data. The spec doesn't care what the backend of the terminal emulator is (e.g. a graphical canvas, or a browser (HTML DOM), or another terminal emulator (tmux)), it's the terminal emulator's task to implement the specified behavior by whatever means. And one aspect of the specified behavior is that in some circumstances the character cells need to be shuffled according to the BiDi algorithm (for display purposes only, not affecting the actual storage), because that's the only reasonable way to get simple utilities like "cat" produce the desired output; and in some other circumstances the cells mustn't be rearranged, because that's the only way vim/emacs/whoever can do their own BiDi. There are escape sequences controlling this behavior. And there's much-much more to the story than this. |
Please see the published draft BiDi specification at https://terminal-wg.pages.freedesktop.org/bidi/ . Comments, improvement ideas etc. are welcome over there in its issue tracker. |
I just had this issue in vscode terminal is there still no fix for this? |
Not sure what the current state of this issue is? Some old comments mention PRs fixing it, but it's still active in the latest vsc insiders. :'( |
I have the same issue. This issue is like Adobe's photoshop problem. in adobe, we can go to language settings and enable middle eastern features for fixing this issue. But we do have not any solution in vs code. Check this link: I have Windows 11 and I have not any problem in manual running code in CMD or Powershell. But VS Code not working correctly. Please fix this. |
hi. i wanted to migrate from pycharm to vscode, but this is a blocker. in pycharm the terminal works fine with RTL. was anyone able to get vscode terminal work for Hebrew? |
@Tyriar whould you please guide me to solve this? |
@par3ae this needs a bunch of research to figure out how to solve it properly which I haven't had time to do. |
Related question on Stack Overflow: Why doesn't the VS Code integrated terminal support RTL (right-to-left) text? |
Arabic and Hebrew script have been mentioned, but there are many more scripts that require bidi support. But it is also not just of a question of bidirectional text, all writing systems requiring complex rendering seem to be affected. Every South Asian and South East Asian script I tried was broken, as were quite a few African scripts. |
@andjc Yes - to make it blunt, unicode in terminal emulators is broken, when it comes to script systems outside of the latin/greek derived systems. Mainly 3 things are missing in xterm.js:
Regarding bidi and xterm.js - since we have no devs with an RTL background, it is unlikely to be adopted soon. Speaking for myself - I have literally no clue about bidi mechs, and would just end up messing with a system I dont know/understand. |
@jerch, assuming a solution to the extended grapheme clusters is found, it will then be necessary to rethink the grid system. East Asian Width property and two cell sizes may not be adequate, some grapheme clusters become quite complex, and if the base character is wide to start with ... Bidi is one issue, but visual versus logical ordering is another issue: Take grapheme "ကြွေ" (U+1000 U+103C U+103D U+1031), U+1031 is rendered at the beginning of the cluster but is the fourth character in the string. Honestly, it quickly becomes extremely complex to implement. Most terminals work best for LCG, and even for LCG they don't necessarily play nice with all input frameworks either. |
I wonder if using a library like bidi-js as a pre-processor can mitigate the issue for now. |
Downstream issue: microsoft/vscode#28571
When we enforced unicode character width in #467 this broke RTL language characters as they are now rendered in reverse (LTR). We could revert that for RTL character ranges only but we should do the right fix and reverse the strings so they're actually on the character grid as the new selection model relies on all characters lining up perfectly on the grid #670
Ideally line reflow #622 would be done before this so it's easier to change the contents of multiple lines.
Terminal.app:
VS Code 1.13 (notice sentences are reversed):
@mostafa69d @CherryDT a little info on the languages in question would be handy:
Useful references:
The text was updated successfully, but these errors were encountered: