Skip to content

Commit

Permalink
Fix broken monaco API to get theme details (zikaari#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
IamAfnanSk authored Jun 10, 2021
1 parent 7a36a0b commit 6f5bcdc
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ export async function liftOff() {

## Limitation

**Version Issue!**

The latest version of this package requires `monaco-editor` version `0.21.1` and up. Version `2.2.2`
was the last version to support `monaco-editor` version `0.19.x` or below.

`monaco-editor` distribution comes with built-in tokenization support for few languages. Because of this `monaco-editor-textmate` [cannot
be used with `monaco-editor`](https://github.com/Microsoft/monaco-editor/issues/884) without some modification, see explanation of this problem [here](https://github.com/Microsoft/monaco-editor/issues/884#issuecomment-389778611).

Expand Down
133 changes: 133 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
"monaco-editor": "0.x.x",
"monaco-textmate": "^3.0.0"
}
}
}
6 changes: 3 additions & 3 deletions src/tm-to-monaco-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ export const TMToMonacoToken = (editor: monacoNsps.editor.ICodeEditor, scopes: s
if (char === ".") {
const token = scope.slice(0, i);
if (
editor['_themeService'].getTheme()._tokenTheme._match(token + "." + scopeName)._foreground >
editor['_themeService'].getColorTheme()._tokenTheme._match(token + "." + scopeName)._foreground >
1
) {
return token + "." + scopeName;
}
if (editor['_themeService'].getTheme()._tokenTheme._match(token)._foreground > 1) {
if (editor['_themeService'].getColorTheme()._tokenTheme._match(token)._foreground > 1) {
return token;
}
}
}
}

return "";
};
};

0 comments on commit 6f5bcdc

Please sign in to comment.