在 CompletionItem 中设置光标位置
Set cursor location in CompletionItem
我想将数字添加到 sass-缩进扩展中,我有点想出了怎么做,如果我能像你一样在触发建议时设置光标位置就好了用 </code> 制作片段时可以设置光标位置,可以吗?</p>
<pre><code>import { CompletionItem, CompletionItemKind } from 'vscode';
const sassSchemaTest = [
{
name: '%',
body: '%', // I want the cursor location where the '$' sign is
description: 'test'
}
];
export default sassSchemaTest.map(item => {
const completionItem = new CompletionItem(item.name);
completionItem.insertText = item.body;
completionItem.detail = item.description;
completionItem.kind = CompletionItemKind.Property;
return completionItem;
});
是的,完成项支持 usual snippet syntax. Simply use a vscode.SnippetString
for insertText
而不是原始 string
。
A string or snippet that should be inserted in a document when selecting this completion. When falsy
the label is used.
completionItem.insertText = new vscode.SnippetString(item.body);
我想将数字添加到 sass-缩进扩展中,我有点想出了怎么做,如果我能像你一样在触发建议时设置光标位置就好了用 </code> 制作片段时可以设置光标位置,可以吗?</p>
<pre><code>import { CompletionItem, CompletionItemKind } from 'vscode';
const sassSchemaTest = [
{
name: '%',
body: '%', // I want the cursor location where the '$' sign is
description: 'test'
}
];
export default sassSchemaTest.map(item => {
const completionItem = new CompletionItem(item.name);
completionItem.insertText = item.body;
completionItem.detail = item.description;
completionItem.kind = CompletionItemKind.Property;
return completionItem;
});
是的,完成项支持 usual snippet syntax. Simply use a vscode.SnippetString
for insertText
而不是原始 string
。
A string or snippet that should be inserted in a document when selecting this completion. When
falsy
the label is used.
completionItem.insertText = new vscode.SnippetString(item.body);