Skip to content

Resolve webview viewColumn after creating ViewColumn.Beside panel#315506

Open
yogeshwaran-c wants to merge 1 commit into
microsoft:mainfrom
yogeshwaran-c:fix/webview-viewcolumn-beside-233448
Open

Resolve webview viewColumn after creating ViewColumn.Beside panel#315506
yogeshwaran-c wants to merge 1 commit into
microsoft:mainfrom
yogeshwaran-c:fix/webview-viewcolumn-beside-233448

Conversation

@yogeshwaran-c
Copy link
Copy Markdown
Contributor

Fixes #233448

When an extension calls vscode.window.createWebviewPanel(id, title, vscode.ViewColumn.Beside), webviewPanel.viewColumn keeps returning undefined instead of resolving to the concrete column the panel was placed in.

Cause

MainThreadWebviewPanels.$createWebviewPanel does:

  1. _webviewWorkbenchService.openWebview(...) — actually creates and places the webview, which fires editor-service events.
  2. addWebviewInput(handle, webview, ...) — registers the handle for the new input.

The events from step 1 trigger updateWebviewViewStates, but at that moment the new webview is not yet in _webviewInputs, so getHandleForInput returns undefined and the resolved view state is never pushed to the extension host. The ext-host getter therefore continues to see the symbolic value (-2 for Beside) and returns undefined.

Fix

After registering the handle, explicitly call updateWebviewViewStates(activeEditor) once. This causes the resolved column to be pushed back to the extension host immediately, so symbolic columns (ViewColumn.Beside, ViewColumn.Active) resolve to a concrete column right after creation. This matches the documented behavior of TextEditor.viewColumn, which the user explicitly compared against in the issue.

The change is a one-call addition; existing event-driven updates remain in place for subsequent group/visibility changes.

Editor events fired during openWebview run before the new webview's handle
is registered with addWebviewInput, so updateWebviewViewStates can't find
the handle and never sends the resolved viewColumn to the extension host.
Push the view state explicitly after registering the handle so symbolic
columns (ViewColumn.Beside, ViewColumn.Active) resolve to a concrete
column immediately, matching showTextDocument behavior.

Fixes microsoft#233448
Copilot AI review requested due to automatic review settings May 10, 2026 03:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a race in the workbench ↔ extension-host synchronization for newly created webview panels opened with symbolic columns (notably ViewColumn.Beside), ensuring webviewPanel.viewColumn resolves to a concrete column immediately after creation.

Changes:

  • After registering the webview handle, explicitly pushes a view-state update so the extension host receives the resolved editor column for the new webview panel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

webviewPanel.viewColumn set incorrectly

3 participants