这应该是可行的:
const vscode = require('vscode')
async function commentLine() {
const success = await vscode.commands
.executeCommand('vscode.editorScroll', {
to:'down',
by: 'halfPage',
revealCursor: true,
});
console.log(success)
}
但是,在用户操作之后运行此代码时,我在警告模式中收到了'vscode.revealCursor` is unknown‘命令。
你知道为什么这不管用吗?
发布于 2019-09-05 12:21:31
实际的错误消息是:
command 'vscode.editorScroll' not found
问题不是revealCursor
,而是命令名上的vscode.
前缀。将executeCommand
first参数更改为"editorScroll"
,它就可以工作了。
此外,此特定命令不返回任何内容,因此success
为undefined
。
https://stackoverflow.com/questions/57802474
复制相似问题