11import {
22 WebviewPanel ,
3- ExtensionContext ,
43 window as Window ,
54 ViewColumn ,
65 Uri ,
98} from "vscode" ;
109import { join } from "path" ;
1110
11+ import { App } from "../app" ;
1212import { DisposableObject , DisposeHandler } from "../disposable-object" ;
1313import { tmpDir } from "../../tmp-dir" ;
1414import { getHtmlForWebview , WebviewMessage , WebviewKind } from "./webview-html" ;
@@ -34,7 +34,7 @@ export abstract class AbstractWebview<
3434
3535 private panelResolves ?: Array < ( panel : WebviewPanel ) => void > ;
3636
37- constructor ( protected readonly ctx : ExtensionContext ) {
37+ constructor ( protected readonly app : App ) {
3838 super ( ) ;
3939 }
4040
@@ -50,8 +50,6 @@ export abstract class AbstractWebview<
5050
5151 protected async getPanel ( ) : Promise < WebviewPanel > {
5252 if ( this . panel === undefined ) {
53- const { ctx } = this ;
54-
5553 // This is an async method, so in theory this method can be called concurrently. To ensure that we don't
5654 // create two panels, we use a promise that resolves when the panel is created. This way, if the panel is
5755 // being created, the promise will resolve when it is done.
@@ -81,7 +79,7 @@ export abstract class AbstractWebview<
8179 localResourceRoots : [
8280 ...( config . additionalOptions ?. localResourceRoots ?? [ ] ) ,
8381 Uri . file ( tmpDir . name ) ,
84- Uri . file ( join ( ctx . extensionPath , "out" ) ) ,
82+ Uri . file ( join ( this . app . extensionPath , "out" ) ) ,
8583 ] ,
8684 } ,
8785 ) ;
@@ -99,19 +97,15 @@ export abstract class AbstractWebview<
9997
10098 protected setupPanel ( panel : WebviewPanel , config : WebviewPanelConfig ) : void {
10199 this . push (
102- panel . onDidDispose (
103- ( ) => {
104- this . panel = undefined ;
105- this . panelLoaded = false ;
106- this . onPanelDispose ( ) ;
107- } ,
108- null ,
109- this . ctx . subscriptions ,
110- ) ,
100+ panel . onDidDispose ( ( ) => {
101+ this . panel = undefined ;
102+ this . panelLoaded = false ;
103+ this . onPanelDispose ( ) ;
104+ } , null ) ,
111105 ) ;
112106
113107 panel . webview . html = getHtmlForWebview (
114- this . ctx ,
108+ this . app ,
115109 panel . webview ,
116110 config . view ,
117111 {
@@ -123,7 +117,6 @@ export abstract class AbstractWebview<
123117 panel . webview . onDidReceiveMessage (
124118 async ( e ) => this . onMessage ( e ) ,
125119 undefined ,
126- this . ctx . subscriptions ,
127120 ) ,
128121 ) ;
129122 }
0 commit comments