-1

I have uploaded my code at https://github.com/Hfutsora/monaco-kaco.

Steps to reproduce:

  1. Open github page https://hfutsora.github.io/monaco-kaco/
  2. Enter char 'O' at the endline then you can get suggestion
    provide suggestions
  3. Enter char 'O' before the endline there are no suggestions appeared
    none suggestion
Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
hfutsora
  • 91
  • 4

2 Answers2

0

I think the problem is that VS Code filters out your candidates because it gets the wrong already typed characters. In my completion providers I use a different method:

const info = model.getWordUntilPosition(position);

which finds the word before the current caret position.

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
  • I have checked the suggestions' range and found `monaco.languages.CompletionItem.range` note that The range must be a single line and it must contain the position at which completion has been requested. So the problem was provided the error range because when enter before the endline, position.lineNumber and model.getLineCount() were not the sameline! – hfutsora Mar 16 '22 at 01:37
0

CompletionItem.Range Note

The range in CompletionItem must be a SingleLine, I provided a error range with different startLine and endLine, I thought this was the problem.

monaco.Range({
  position.lineNumber,
  word?.startColumn ?? position.column,
  model.getLineCount(), // not the same line
  model.getLineMaxColumn(model.getLineCount())
})
hfutsora
  • 91
  • 4