-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Mosè Giordano edited this page Feb 19, 2021
·
6 revisions
Welcome to the vscode-language-sample wiki!
We want to provide a straightforward way for users to work with right-to-left (RTL) scripts, such as Arabic. Unfortunately Visual Studio Code doesn't natively support them, as reported several times:
- Issue with most of the discussion
- Similar issue with discussion of possible solution
- Another related issue which is in backlog of the developers
If proper support for RTL scripts was included in Visual Studio Code, there would basically be nothing for us to do in this regard. However we need to work around this limitation. One way to do it is to show the Arabic translation of the text in a separate pane, using webviews, similar to how the default Markdown extension shows the preview of the text, see below for further details.
We looked at the Markdown preview functionality which is built into VS code.
- The Markdown extension seems to be split in two: markdown-basic has, well, basic stuff, and markdown-language-features has all the webview stuff.
- The latter seems to be pretty generic? Or at least the general structure could be replicated, even if not inheriting from the code directly.
- Commands can be defined in a separate class...
- ...and then registered by instantiating that class
- A command to refresh the webview goes through several layers of managers, collections etc, until eventually it calls a method in a content provider class.
- There is a check so that the webview is not rendered needlessly (through a concept of versions).
- All of this is done in Typescript, without embedding a Javascript script (or at least the script that is embedded does not seem relevant).
- We think that the preview is automatically refreshed by listening to changes in the underlying document.