diff --git a/src/plugins/data/public/plugin.ts b/src/plugins/data/public/plugin.ts index ced04c4de9cc..ba32243412df 100644 --- a/src/plugins/data/public/plugin.ts +++ b/src/plugins/data/public/plugin.ts @@ -170,7 +170,7 @@ export class DataPublicPlugin const ac = this.autocomplete.setup(core); ac.addQuerySuggestionProvider('PPL', getPPLSuggestions); - ac.addQuerySuggestionProvider('SQL', getDQLSuggestions); + ac.addQuerySuggestionProvider('SQL', getSQLSuggestions); ac.addQuerySuggestionProvider('kuery', getDQLSuggestions); return { diff --git a/src/plugins/data/public/ui/query_editor/query_editor.tsx b/src/plugins/data/public/ui/query_editor/query_editor.tsx index 1d4a5e5c4c34..23af96d59051 100644 --- a/src/plugins/data/public/ui/query_editor/query_editor.tsx +++ b/src/plugins/data/public/ui/query_editor/query_editor.tsx @@ -37,8 +37,11 @@ import { QueryLanguageSelector } from './language_selector'; import { QueryEditorExtensions } from './query_editor_extensions'; import { QueryEditorBtnCollapse } from './query_editor_btn_collapse'; -const LANGUAGE_ID = 'kuery'; -monaco.languages.register({ id: LANGUAGE_ID }); +const LANGUAGE_ID_SQL = 'SQL'; +monaco.languages.register({ id: LANGUAGE_ID_SQL }); + +const LANGUAGE_ID_KUERY = 'kuery'; +monaco.languages.register({ id: LANGUAGE_ID_KUERY }); export interface QueryEditorProps { indexPatterns: Array; @@ -298,7 +301,7 @@ export default class QueryEditorUI extends Component { } public componentDidUpdate(prevProps: Props) { - if (prevProps.indexPatterns !== this.props.indexPatterns) { + if (!isEqual(prevProps.indexPatterns, this.props.indexPatterns)) { this.fetchIndexPatterns(); } diff --git a/src/plugins/opensearch_dashboards_react/public/code_editor/code_editor.tsx b/src/plugins/opensearch_dashboards_react/public/code_editor/code_editor.tsx index 5dc0d94ba00f..26ab5b482a48 100644 --- a/src/plugins/opensearch_dashboards_react/public/code_editor/code_editor.tsx +++ b/src/plugins/opensearch_dashboards_react/public/code_editor/code_editor.tsx @@ -127,31 +127,31 @@ export class CodeEditor extends React.Component { this.props.editorWillMount(); } - monaco.languages.onLanguage(this.props.languageId, () => { - if (this.props.suggestionProvider) { - monaco.languages.registerCompletionItemProvider( - this.props.languageId, - this.props.suggestionProvider - ); - } - - if (this.props.signatureProvider) { - monaco.languages.registerSignatureHelpProvider( - this.props.languageId, - this.props.signatureProvider - ); - } - - if (this.props.hoverProvider) { - monaco.languages.registerHoverProvider(this.props.languageId, this.props.hoverProvider); - } - - if (this.props.languageConfiguration) { - monaco.languages.setLanguageConfiguration( - this.props.languageId, - this.props.languageConfiguration - ); - } + // TEMPORARY fix for suggestion providor not appear for more than one language + ['SQL', 'kuery'].forEach((language) => { + monaco.languages.onLanguage(language, () => { + if (this.props.suggestionProvider) { + monaco.languages.registerCompletionItemProvider(language, this.props.suggestionProvider); + } + + if (this.props.signatureProvider) { + monaco.languages.registerSignatureHelpProvider( + this.props.languageId, + this.props.signatureProvider + ); + } + + if (this.props.hoverProvider) { + monaco.languages.registerHoverProvider(this.props.languageId, this.props.hoverProvider); + } + + if (this.props.languageConfiguration) { + monaco.languages.setLanguageConfiguration( + this.props.languageId, + this.props.languageConfiguration + ); + } + }); }); // Register the theme