在 VSCode 中执行编辑器滚动命令
Execute command for editor scroll in VSCode
应该可行:
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 command”。
知道为什么这不起作用吗?
实际的错误信息是:
command 'vscode.editorScroll' not found
问题不在于 revealCursor
,问题在于命令名称的 vscode.
前缀。将 executeCommand
第一个参数更改为 "editorScroll"
即可。
此外,此特定命令不 return 任何内容,因此 success
是 undefined
。
应该可行:
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 command”。
知道为什么这不起作用吗?
实际的错误信息是:
command 'vscode.editorScroll' not found
问题不在于 revealCursor
,问题在于命令名称的 vscode.
前缀。将 executeCommand
第一个参数更改为 "editorScroll"
即可。
此外,此特定命令不 return 任何内容,因此 success
是 undefined
。