Repository: vscode
Issue: Support for RTL languages (such as Arabic / Hebrew / Persian etc.)
Labels: feature-request,editor-RTL

My name is Tomer Mahlin. I lead a development team in IBM named Bidi Development Lab. We are specializing (for more than 20 years) in development of support for languages with bidirectional scripts (or "bidi lang." for short) . 

We recently ran a sniff assessment on Monaco capabilities with respect to bidi lang. display. We believe there are several functional areas which require improvements (please see more details below). 
My team can work on necessary modifications and suggest them via separate pull request, assuming community is interested in addressing the requirements detailed below. 

**Plain text editing**
1. There should be a parameter through which it will be possible to communicated the default text direction for content being authored in specific instance of editor. This is a similar parameter to what is used in CKEditor: contentsLangDirection ( http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-contentsLangDirection ).
Possible values should be:
- ltr (left-to-right),
- rtl (right-to-left),
- contextual (or auto as used in HTML)

2. In addition to that, there should be explicit way for the end user to interactively change text direction for selected text (or for current paragraph in which cursor is positioned in case current selection is of zero length). This can be achieved via:
 - GUI buttons - similar to all rich text editors (i.e. http://ckeditor.com/addon/bidi)
AND / OR (in case there is no toolbars for any new buttons)
- Keyboard shortcuts (i.e. in Notepad it is Ctrl - <Left|Right-Shift>)  

**Programming lang. editing**
1. As opposed to plain text, programming lang has well defined syntax. Some part of this syntax is visualized via color schema used for coloring different elements (i..e comments vs variables etc.) of the language.  It is critical to enforce visual appearance associated with the syntax regardless of language used for different elements (i.e. comments, variables etc.). If this is not done, it becomes virtually impossible to work with the code when bidi text is used.  Simple English example: 
a = b + c; // hello world 
If bidi characters are used instead you would expect to see:
A = B + C; // DLROW OLLEH
Instead at the moment you see:
DLROW OLLEH // ;C+B=A
The more complex example can be, less intuitive the display will become. 

2. Special case is the case of comments or/and constants. Those by all means usually include bidi characters (or at least much more frequently than variables names for example). It is thus preferable to display text in those contexts using natural text direction for bidi languages (which is RTL). We can't store text direction information with text (namely source code file is still a plain text file which can't include any meta information about text such as font size, color, direction etc.). Consequently we should be able to make a smart choice while displaying the text (relying just on the text itself). Most straightforward approach is to enforce auto (aka contextual or first strong) direction of text for each paragraph included in comments. 
For example, currently the display of sample text is as follows:
res = var1 + var2; // SI EMAN YM tomer !!!
If we enforce auto text direction on the comment we will see:
res = var1 + var2; // !!! tomer SI EMAN YM
Namely text of comment will appear with actual RTL direction which is a natural one for bidi lang. 
Display of text with natural text direction makes it considerably more readable and thus should greatly enhance user experience for bidi users.

**Relevant requests**
At some point support for bidi lang. was requested in vscode via https://github.com/Microsoft/vscode/issues/4994