应该可以:
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”是未知命令。
有人知道为什么这行不通吗?
答案 0 :(得分:1)
实际错误消息是:
command 'vscode.editorScroll' not found
问题不是revealCursor
,问题是命令名上的vscode.
前缀。只需将executeCommand
的第一个参数更改为"editorScroll"
即可。
此特定命令也不返回任何内容,因此success
是undefined
。