@@ -38,11 +38,37 @@ class ReactWebView {
3838this . panel = this . createWebviewPanel ( vscode . ViewColumn . Two )
3939
4040// Set the webview initial html content
41- this . getHtmlForWebview ( )
41+ this . render ( ) . then ( ( html :string ) => {
42+ this . panel . webview . html = html
43+ // Listen for when the panel is disposed
44+ // This happens when the user closes the panel or when the panel is closed programmatically
45+ this . panel . onDidDispose ( this . dispose , this , this . disposables )
46+
47+
48+ // update panel on changes
49+ const updateWindows = ( ) => {
50+ vscode . commands . executeCommand ( 'vscode.setEditorLayout' , {
51+ orientation :0 ,
52+ groups :[ { groups :[ { } ] , size :0.6 } , { groups :[ { } ] , size :0.4 } ] ,
53+ } )
54+ }
55+
56+ // prevents new panels from going on top of coderoad panel
57+ vscode . window . onDidChangeActiveTextEditor ( ( textEditor ?:vscode . TextEditor ) => {
58+ // console.log('onDidChangeActiveTextEditor')
59+ // console.log(textEditor)
60+ if ( ! textEditor || textEditor . viewColumn !== vscode . ViewColumn . Two ) {
61+ updateWindows ( )
62+ }
63+ } )
64+ // // prevents moving coderoad panel on top of left panel
65+ vscode . window . onDidChangeVisibleTextEditors ( ( textEditor :vscode . TextEditor [ ] ) => {
66+ // console.log('onDidChangeVisibleTextEditors')
67+ updateWindows ( )
68+ } )
4269
43- // Listen for when the panel is disposed
44- // This happens when the user closes the panel or when the panel is closed programmatically
45- this . panel . onDidDispose ( this . dispose , this , this . disposables )
70+ // TODO: prevent window from moving to the left when no windows remain on rights
71+ } )
4672
4773// channel connects webview to the editor
4874this . channel = new Channel ( {
@@ -55,31 +81,6 @@ class ReactWebView {
5581const receive = this . channel . receive
5682this . panel . webview . onDidReceiveMessage ( receive , null , this . disposables )
5783this . send = this . channel . send
58-
59-
60- // update panel on changes
61- const updateWindows = ( ) => {
62- vscode . commands . executeCommand ( 'vscode.setEditorLayout' , {
63- orientation :0 ,
64- groups :[ { groups :[ { } ] , size :0.6 } , { groups :[ { } ] , size :0.4 } ] ,
65- } )
66- }
67-
68- // prevents new panels from going on top of coderoad panel
69- vscode . window . onDidChangeActiveTextEditor ( ( textEditor ?:vscode . TextEditor ) => {
70- // console.log('onDidChangeActiveTextEditor')
71- // console.log(textEditor)
72- if ( ! textEditor || textEditor . viewColumn !== vscode . ViewColumn . Two ) {
73- updateWindows ( )
74- }
75- } )
76- // // prevents moving coderoad panel on top of left panel
77- vscode . window . onDidChangeVisibleTextEditors ( ( textEditor :vscode . TextEditor [ ] ) => {
78- // console.log('onDidChangeVisibleTextEditors')
79- updateWindows ( )
80- } )
81-
82- // TODO: prevent window from moving to the left when no windows remain on rights
8384}
8485
8586public createOrShow ( column :number ) :void {
@@ -113,7 +114,7 @@ class ReactWebView {
113114return vscode . window . createWebviewPanel ( viewType , title , column , config )
114115}
115116
116- private getHtmlForWebview = async ( ) :Promise < void > => {
117+ private render = async ( ) :Promise < string > => {
117118
118119const dom = await JSDOM . fromFile ( './build/index.html' )
119120
@@ -170,7 +171,7 @@ class ReactWebView {
170171
171172console . log ( html )
172173
173- this . panel . webview . html = html
174+ return html
174175}
175176
176177}