@@ -35,7 +35,7 @@ class ReactWebView {
35
35
this . extensionPath = extensionPath
36
36
37
37
// Create and show a new webview panel
38
- this . panel = this . createWebviewPanel ( vscode . ViewColumn . Two )
38
+ this . panel = this . createWebviewPanel ( )
39
39
40
40
// Set the webview initial html content
41
41
this . render ( )
@@ -46,23 +46,16 @@ class ReactWebView {
46
46
47
47
48
48
// update panel on changes
49
- const updateWindows = ( ) => {
50
- vscode . commands . executeCommand ( 'coderoad.open_webview' )
51
- }
49
+ // const updateWindows = () => {
50
+ // vscode.commands.executeCommand('coderoad.open_webview')
51
+ // }
52
52
53
- // prevents new panels from going on top of coderoad panel
54
- vscode . window . onDidChangeActiveTextEditor ( ( textEditor ?: vscode . TextEditor ) => {
55
- // console.log('onDidChangeActiveTextEditor')
56
- // console.log(textEditor)
57
- if ( ! textEditor || textEditor . viewColumn !== vscode . ViewColumn . Two ) {
58
- updateWindows ( )
59
- }
60
- } )
61
- // // prevents moving coderoad panel on top of left panel
62
- vscode . window . onDidChangeVisibleTextEditors ( ( textEditor : vscode . TextEditor [ ] ) => {
63
- // console.log('onDidChangeVisibleTextEditors')
64
- updateWindows ( )
65
- } )
53
+ // // // prevents moving coderoad panel on top of left panel
54
+ // vscode.window.onDidChangeVisibleTextEditors((textEditors: vscode.TextEditor[]) => {
55
+ // console.log('onDidChangeVisibleTextEditors')
56
+ // console.log(textEditors)
57
+ // // updateWindows()
58
+ // })
66
59
67
60
// TODO: prevent window from moving to the left when no windows remain on rights
68
61
@@ -81,13 +74,21 @@ class ReactWebView {
81
74
this . send = this . channel . send
82
75
}
83
76
84
- public createOrShow ( column : number ) : void {
77
+ public createOrShow ( ) : void {
78
+ vscode . commands . executeCommand ( 'vscode.setEditorLayout' , {
79
+ orientation : 0 ,
80
+ groups : [ { groups : [ { } ] , size : 0.6 } , { groups : [ { } ] , size : 0.4 } ] ,
81
+ } )
85
82
// If we already have a panel, show it.
86
83
// Otherwise, create a new panel.
84
+
87
85
if ( this . panel && this . panel . webview ) {
88
- this . panel . reveal ( column )
86
+ if ( ! this . loaded ) {
87
+ this . panel . reveal ( vscode . ViewColumn . Two )
88
+ this . loaded = true
89
+ }
89
90
} else {
90
- this . panel = this . createWebviewPanel ( column )
91
+ this . panel = this . createWebviewPanel ( )
91
92
}
92
93
}
93
94
@@ -98,7 +99,7 @@ class ReactWebView {
98
99
Promise . all ( this . disposables . map ( ( x ) => x . dispose ( ) ) )
99
100
}
100
101
101
- private createWebviewPanel = ( column : number ) : vscode . WebviewPanel => {
102
+ private createWebviewPanel = ( ) : vscode . WebviewPanel => {
102
103
const viewType = 'CodeRoad'
103
104
const title = 'CodeRoad'
104
105
const config = {
@@ -109,7 +110,8 @@ class ReactWebView {
109
110
// prevents destroying the window when it is in the background
110
111
retainContextWhenHidden : true ,
111
112
}
112
- return vscode . window . createWebviewPanel ( viewType , title , column , config )
113
+ this . loaded = true
114
+ return vscode . window . createWebviewPanel ( viewType , title , vscode . ViewColumn . Two , config )
113
115
}
114
116
115
117
private render = async ( ) : Promise < void > => {
0 commit comments