首页 > 解决方案 > 如何获取用户从 VSCode 扩展打开的 ViewColumns 的数量?

问题描述

我正在开发一个 VSCode 扩展,并使用以下命令打开一个 webview:

const panel = vscode.window.createWebviewPanel(
                'webviewName', // Identifies the type of the webview. Used internally
                'Webview Title', // Title of the panel displayed to the user
                vscode.ViewColumn.Two, // Editor column to show the new webview panel in.
                {} // Webview options.
            );

请注意ViewColumn.Two传递给它的参数。这会影响 webview 成为哪个视图列的一部分。

我的预期行为是让 webview 始终向一侧敞开。这意味着如果用户打开了一个文件,那么我可以在 ViewColumn 2 中打开它。但是,如果他们并排打开两个文件,我需要在 ViewColumn 3 中打开它,依此类推。

如何从 VSCode API 获取当前窗口中 ViewColumns 的数量?

另请注意:visual-studio-code-extensions 标签不存在。我想创建它,但我没有足够的代表。

标签: visual-studio-codevscode-extensions

解决方案


也许您正在寻找vscode.ViewColumn.Beside

一个符号编辑器列,表示活动列旁边的列。


推荐阅读