有没有一种方法可以在不使用 Visual Studio 代码中的键绑定 (Ctrl + Space) 的情况下在引号中启用智能感知自动完成
Is there a way to enable intellisense autocomplete in quotes without using key binding (Ctrl + Space) in Visual Studio Code
我想为 Visual Studio 代码开发一个扩展。
我已经为打字稿注册了一个 CompletionItemProvider,当我试图用引号写的时候自动完成不起作用。
例如我有这个代码:
function buildProvider(language : vscode.DocumentSelector, label : string, text : string | vscode.CompletionItemLabel){
return vscode.languages.registerCompletionItemProvider('typescript', {
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext) {
const simpleCompletion = new vscode.CompletionItem('', vscode.CompletionItemKind.Text);
simpleCompletion.label = label;
simpleCompletion.insertText = text.toString();
return [
simpleCompletion,
];
}
});
}
如果我用打字稿写自动完成工作:
Auto completion works
如果我用引号写的话,不使用 Ctrl + Space.
是行不通的
Auto completion does not works
如何启用引号自动完成功能?
该行为在字符串中不起作用,可能是以下设置的结果:
editor.quickSuggestions
.
试试这样设置:
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": true // this is the key setting, default is false3
}
这将为您或具有相同 "strings": true
设置的任何人解决此问题。
您可以在您的`package.json 中像这样在扩展程序中更改用户的默认设置 - 请注意他们可能不喜欢您更改他们的设置!!:
> #### Configuration Defaults Overrides
>
>
> You can now override defaults of other registered configurations
> through `configurationDefaults` contribution point in `package.json`.
> For example, the following snippet overrides the default behavior of
> `files.autoSave` setting to auto save files on focus change.
```jsonc
"contributes": {
"configurationDefaults": { // applies to all languages
"files.autoSave": "onFocusChange"
}
}
Note: Configurations with application or machine scopes cannot be
overridden.
我想为 Visual Studio 代码开发一个扩展。 我已经为打字稿注册了一个 CompletionItemProvider,当我试图用引号写的时候自动完成不起作用。 例如我有这个代码:
function buildProvider(language : vscode.DocumentSelector, label : string, text : string | vscode.CompletionItemLabel){
return vscode.languages.registerCompletionItemProvider('typescript', {
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext) {
const simpleCompletion = new vscode.CompletionItem('', vscode.CompletionItemKind.Text);
simpleCompletion.label = label;
simpleCompletion.insertText = text.toString();
return [
simpleCompletion,
];
}
});
}
如果我用打字稿写自动完成工作:
Auto completion works
如果我用引号写的话,不使用 Ctrl + Space.
是行不通的Auto completion does not works
如何启用引号自动完成功能?
该行为在字符串中不起作用,可能是以下设置的结果:
editor.quickSuggestions
.
试试这样设置:
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": true // this is the key setting, default is false3
}
这将为您或具有相同 "strings": true
设置的任何人解决此问题。
您可以在您的`package.json 中像这样在扩展程序中更改用户的默认设置 - 请注意他们可能不喜欢您更改他们的设置!!:
> #### Configuration Defaults Overrides
>
>
> You can now override defaults of other registered configurations
> through `configurationDefaults` contribution point in `package.json`.
> For example, the following snippet overrides the default behavior of
> `files.autoSave` setting to auto save files on focus change.
```jsonc
"contributes": {
"configurationDefaults": { // applies to all languages
"files.autoSave": "onFocusChange"
}
}
Note: Configurations with application or machine scopes cannot be overridden.