简体   繁体   English

为什么 CompletionItemProvider 在输入字符时不起作用?

[英]Why CompletionItemProvider not work when enter charactor?

I have uploaded my code at https://github.com/Hfutsora/monaco-kaco .我已经在https://github.com/Hfutsora/monaco-kaco上传了我的代码。

Steps to reproduce:重现步骤:

  1. Open github page https://hfutsora.github.io/monaco-kaco/打开github页面https://hfutsora.github.io/monaco-kaco/
  2. Enter char 'O' at the endline then you can get suggestion在末尾输入字符'O'然后你可以得到建议
    提供建议
  3. Enter char 'O' before the endline there are no suggestions appeared在结束行之前输入字符'O' 没有出现任何建议
    没有建议

I think the problem is that VS Code filters out your candidates because it gets the wrong already typed characters.我认为问题是 VS Code 过滤掉了你的候选人,因为它得到了错误的already typed的字符。 In my completion providers I use a different method:在我的完成提供者中,我使用了不同的方法:

const info = model.getWordUntilPosition(position);

which finds the word before the current caret position.它会找到当前插入符号 position之前的单词。

CompletionItem.Range Note CompletionItem.Range 注解

The range in CompletionItem must be a SingleLine, I provided a error range with different startLine and endLine, I thought this was the problem. CompletionItem 中的范围必须是 SingleLine,我提供了具有不同 startLine 和 endLine 的错误范围,我认为这是问题所在。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM