VSCODE:如何专注于编辑器

发布于 2025-02-10 05:22:15 字数 171 浏览 3 评论 0原文

在我的Visual Studio代码扩展程序中,我当前调用WorkBench.Action.MoveEditorTonextGroup将编辑器移动代码。但是,如果我调用任何额外的命令,它将使用以前的编辑器组,而不是我将其移至的编辑组。

如何将重点放在某个编辑器上,例如我搬到的编辑器?

In my Visual Studio code extension, I currently call workbench.action.moveEditorToNextGroup which moves the editor in code. However, if I call any extra commands, it will use the previous editor group rather than the one I moved it to.

How can I focus to a certain editor such as the one I move to?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

静若繁花 2025-02-17 05:22:15

看起来workbench.action.focusfirsteditorgroup应该做tick。

另外,

  • workbench.action.focusfirsteditorgroup
  • workbench.action.focussecondoritorgrou

...

也可能是您想要的。

请参阅文档有关完整列表

It looks like workbench.action.focusFirstEditorGroup should do the tick.

Alternatively,

  • workbench.action.focusFirstEditorGroup
  • workbench.action.focusSecondEditorGrou

...

May also be what you are looking for.

See docs for full list

香橙ぽ 2025-02-17 05:22:15

移动编辑器的一种更强大的方法是使用MoveActiveEditor命令。

 const moveTabBetweenGroupArgs = {to: "right", by: "group"};
 await vscode.commands.executeCommand('moveActiveEditor', moveTabBetweenGroupArgs);

最好的文档位于此处: moveActiveEditor解释

如果我反复打电话给它,它使用我刚移动的编辑器。因此,例如,如果我将编辑器移至正确的组,然后再次触发命令,则将同一编辑器移至下一个正确的组。

如果命令还没有,则该命令将在右侧创建一个组。

不幸的是,有了这些选项:

// const moveTabBetweenGroupArgs = {to: "position", by: "group", value: 2};  // 'value' is 1-based

您也应该能够将编辑器移至第二组 - 即使不存在 - 但是此表单不会创建第二组并默默失败。我认为这是一个错误,会提出问题。

您还可以使用MoveActiveEditor命令将编辑器轻松地移动到组中,以这样的代码:

const moveTabInGroupArgs = {to: "position", by: "tab", value: targetIndex + 1};  // 'value' is 1-based
await vscode.commands.executeCommand('moveActiveEditor', moveTabInGroupArgs);

它将将活动编辑器移至value column th3e当前组中的列。 value是基于1的,因此组中的第一列是1,而不是0

A more powerful way to move editors is to use the moveActiveEditor command.

 const moveTabBetweenGroupArgs = {to: "right", by: "group"};
 await vscode.commands.executeCommand('moveActiveEditor', moveTabBetweenGroupArgs);

The best documentation is located here: moveActiveEditor explanation.

If I call that repeatedly, it uses the editor I just moved. So, for instance, if I move an editor to the right group, and then trigger the command again, that same editor is moved to the next right group.

The command will create a group to the right if there isn't already one there.

Unfortunately, with these options:

// const moveTabBetweenGroupArgs = {to: "position", by: "group", value: 2};  // 'value' is 1-based

you should also be able to move an editor to a second group - even if it doesn't exist - but this form will NOT create the second group and silently fails. I consider that a bug and will file an issue.

You can also use the moveActiveEditor command to move editors within groups easily with code like this:

const moveTabInGroupArgs = {to: "position", by: "tab", value: targetIndex + 1};  // 'value' is 1-based
await vscode.commands.executeCommand('moveActiveEditor', moveTabInGroupArgs);

which will move the ACTIVE editor to the value column within th3e current group. The value is 1-based, so the first column in a group is 1, not 0.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文