Open pemj opened 4 years ago
It actually looks like this is an issue with the Monarch definition of shell script. When I checked the tokenization of line 3 in the Monaco playground, it looks like all of the blue text is being interpreted as a single variable:
This ignores the opening quote and bracket contained therein, while the closing bracket gets treated as the end of the statement:
That single quote gets treated as an opening quote instead of a closing quote, and the rest of the file gets interpreted as a string.
The tokenization in VS Code, by contrast, seems to do a pretty decent job of traversing the bash syntax tree.
Found where the issue happens. https://github.com/microsoft/monaco-languages/blob/master/src/shell/shell.ts#L219
The language definition for bash in the monaco-languages repo doesn't appear to support command substitution: just about anything preceded by the characters $(
gets treated as a variable identifier instead of an expression, so the quotes, the single quote, the brackets, the open paren, all of that just kinda gets tossed in there, until the pop statement on line 222 catches the closing paren and decides to call it a day.
+1
+1
FWIW, here's a shellscript language configuration in VSCode which doesn't appear to have this issue:
https://github.com/microsoft/vscode/tree/master/extensions/shellscript
It's a shame that commercial product (Azure DevOps) has worse support than the free one (VSCode)
just thought I'd swing by here for old time's sake, sit down for a spell and appreciate the lovely and pastoral beauty of the ol' prairie, appreciate the sound of crickets chirping in the distance. nothin' much ever changes 'round these parts.
anyway I still have to tell people to pull up a separate editor any time they want to review a PR I make to a bash library I help maintain.
monaco-editor version: 0.20.0 (assuming that's the version on the playground) Browser: Chrome OS: Windows Playground code that reproduces the issue:
I ran into an issue that can be reproduced by displaying the following bash in the Monaco editor, but not VS code:
If typed into Visual Studio Code, version info below,
that text renders correctly, like so:
If you create a file called sample.sh in the visual studio code playground (version info below),
and add bash in question, it will again render correctly:
However, if navigate to the monaco homepage at https://microsoft.github.io/monaco-editor/index.html and select shell, then paste in the sample functions, the syntax highlighting breaks
If you visit the Monaco playground and add this command:
after clicking "run" you get an instance of incorrect highlighting on the right-hand side:
I discovered this issue while using Azure DevOps, where it shows up if you edit a file with a .sh ending:
I've been working on an MS-internal repo full of bash lately, and this bug has been making it a little tricky to review pull requests there.