[8.6] [PresentationUtil] Fix Canvas expression autocomplete (#146425) (#146465)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[PresentationUtil] Fix Canvas expression autocomplete
(#146425)](https://github.com/elastic/kibana/pull/146425)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Nick
Peihl","email":"nick.peihl@elastic.co"},"sourceCommit":{"committedDate":"2022-11-28T19:30:37Z","message":"[PresentationUtil]
Fix Canvas expression autocomplete (#146425)\n\nFixes #146243 \r\n\r\n##
Summary\r\n\r\nFixes Canvas expression
autocomplete\r\n\r\nhttps://github.com/elastic/kibana/pull/143739
upgraded the monaco-editor\r\ndependency which uses a callback to the
`onLanguage` method to\r\ninitialize the expressions. The PR moved the
`monaco.languages.register`\r\ncommand inside this callback and which
was never triggered.\r\n\r\nMoving the `monaco.languages.register`
command outside the callback\r\nappears to fix the
issue.","sha":"19413b7daae983b95dbb9f5c7b39cb8f3578ebfa","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Presentation","release_note:skip","backport:prev-minor","v8.6.0","v8.7.0"],"number":146425,"url":"https://github.com/elastic/kibana/pull/146425","mergeCommit":{"message":"[PresentationUtil]
Fix Canvas expression autocomplete (#146425)\n\nFixes #146243 \r\n\r\n##
Summary\r\n\r\nFixes Canvas expression
autocomplete\r\n\r\nhttps://github.com/elastic/kibana/pull/143739
upgraded the monaco-editor\r\ndependency which uses a callback to the
`onLanguage` method to\r\ninitialize the expressions. The PR moved the
`monaco.languages.register`\r\ncommand inside this callback and which
was never triggered.\r\n\r\nMoving the `monaco.languages.register`
command outside the callback\r\nappears to fix the
issue.","sha":"19413b7daae983b95dbb9f5c7b39cb8f3578ebfa"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/146425","number":146425,"mergeCommit":{"message":"[PresentationUtil]
Fix Canvas expression autocomplete (#146425)\n\nFixes #146243 \r\n\r\n##
Summary\r\n\r\nFixes Canvas expression
autocomplete\r\n\r\nhttps://github.com/elastic/kibana/pull/143739
upgraded the monaco-editor\r\ndependency which uses a callback to the
`onLanguage` method to\r\ninitialize the expressions. The PR moved the
`monaco.languages.register`\r\ncommand inside this callback and which
was never triggered.\r\n\r\nMoving the `monaco.languages.register`
command outside the callback\r\nappears to fix the
issue.","sha":"19413b7daae983b95dbb9f5c7b39cb8f3578ebfa"}}]}]
BACKPORT-->

Co-authored-by: Nick Peihl <nick.peihl@elastic.co>
This commit is contained in:
Kibana Machine 2022-11-28 15:39:06 -05:00 committed by GitHub
parent 3dbe45667d
commit 301bd83458
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 });
}