Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the number of ViewColumns the user has open from a VSCode extension?

I am working on developing a VSCode extension, and I open a webview using the following:

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.
            );

Note the ViewColumn.Two argument that is passed to it. This affects which view column the webview becomes a part of.

My intended behavior is for the webview is to ALWAYS open to the side. This means that if the user has one file open, then I can open it in ViewColumn 2. However, if they had two files open side-by-side, I'd need to open it in ViewColumn three, and so forth.

How do I get the number of ViewColumns in the current window from the VSCode API?

Also a note: The visual-studio-code-extensions tag does not exist. I want to create it but I don't have enough rep.

like image 474
Jaxkr Avatar asked Oct 31 '25 05:10

Jaxkr


1 Answers

Maybe you're looking for vscode.ViewColumn.Beside:

A symbolic editor column representing the column to the side of the active one.

like image 87
mre Avatar answered Nov 01 '25 18:11

mre



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!