首页 > 解决方案 > VSCode extension: code completion of custom language only triggers when invoked

问题描述

I'm the author of the Language support for CloudFormation templates extension. It provides code completion, but right now this is, against my intention, only triggered when invoked (when pressing ctrl+space). I suspect this is because the identifiers in the language are encapsulated in quotes, and VSCode is treating them as strings. However, when I set "strings" to true in "editor.quickSuggestions", the code completion still only works when invoked.

I've tried changing the syntax highlighting grammar so it no longer registers anything as a string, but that did not work. I've also tried specifying a 'wordPattern' in the language configuration that included the quotes, but without luck. (Here's the documentation on word patterns)

标签: visual-studio-codevscode-extensions

解决方案


我发现了问题。我指定的 wordPattern 是“[a-zA-Z]*”,所以当输入“ba[cursorPosition]”时,VS Code 不会触发自动补全,因为它会认为“ba”是一个单词并且光标在中间这个词,此时显然它不会触发自动完成。

将 wordPattern 更改为 "[a-zA-Z]* 解决了该问题。


推荐阅读