diff --git a/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts b/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts index f33b13ff7..48a5c3241 100644 --- a/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts +++ b/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts @@ -191,28 +191,30 @@ export class EoMonacoEditorComponent implements AfterViewInit, OnInit, OnChanges } private initMonacoEditorEvent() { - // this.completionItemProvider = window.monaco.languages.registerCompletionItemProvider('javascript', { - // provideCompletionItems: (model, position) => { - // // find out if we are completing a property in the 'dependencies' object. - // const textUntilPosition = model.getValueInRange({ - // startLineNumber: 1, - // startColumn: 1, - // endLineNumber: position.lineNumber, - // endColumn: position.column, - // }); + if (this.completions?.length) { + this.completionItemProvider = window.monaco.languages.registerCompletionItemProvider('javascript', { + provideCompletionItems: (model, position) => { + // find out if we are completing a property in the 'dependencies' object. + const textUntilPosition = model.getValueInRange({ + startLineNumber: 1, + startColumn: 1, + endLineNumber: position.lineNumber, + endColumn: position.column, + }); - // const word = model.getWordUntilPosition(position); - // const range = { - // startLineNumber: position.lineNumber, - // endLineNumber: position.lineNumber, - // startColumn: word.startColumn, - // endColumn: word.endColumn, - // }; - // return { - // suggestions: this.completions.map((n) => ({ ...n, range })), - // } as any; - // }, - // }); + const word = model.getWordUntilPosition(position); + const range = { + startLineNumber: position.lineNumber, + endLineNumber: position.lineNumber, + startColumn: word.startColumn, + endColumn: word.endColumn, + }; + return { + suggestions: this.completions.map((n) => ({ ...n, range })), + } as any; + }, + }); + } // this.codeEdtor.onDidChangeModelDecorations(() => { // updateEditorHeight(); // typing