[PresentationUtil] Fix Canvas expression autocomplete (#146425)

Fixes #146243 

## Summary

Fixes Canvas expression autocomplete

https://github.com/elastic/kibana/pull/143739 upgraded the monaco-editor
dependency which uses a callback to the `onLanguage` method to
initialize the expressions. The PR moved the `monaco.languages.register`
command inside this callback and which was never triggered.

Moving the `monaco.languages.register` command outside the callback
appears to fix the issue.
This commit is contained in:
Nick Peihl 2022-11-28 14:30:37 -05:00 committed by GitHub
parent 55b59722f7
commit 19413b7daa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -116,7 +116,7 @@ export function registerExpressionsLanguage(functions: ExpressionFunction[]) {
expressionsLanguage.keywords = functions.map((fn) => fn.name);
expressionsLanguage.deprecated = functions.filter((fn) => fn.deprecated).map((fn) => fn.name);
monaco.languages.onLanguage(EXPRESSIONS_LANGUAGE_ID, () => {
monaco.languages.register({ id: EXPRESSIONS_LANGUAGE_ID });
monaco.languages.setMonarchTokensProvider(EXPRESSIONS_LANGUAGE_ID, expressionsLanguage);
});
monaco.languages.register({ id: EXPRESSIONS_LANGUAGE_ID });
}