在VSCode中执行编辑器滚动的命令

时间:2019-09-05 09:32:41

标签: scroll visual-studio-code command

应该可以:

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”是未知命令。

有人知道为什么这行不通吗?

1 个答案:

答案 0 :(得分:1)

实际错误消息是:

command 'vscode.editorScroll' not found

问题不是revealCursor,问题是命令名上的vscode.前缀。只需将executeCommand的第一个参数更改为"editorScroll"即可。

此特定命令也不返回任何内容,因此successundefined