@@ -18,7 +18,6 @@ const COMMANDS = {
1818RUN_TEST :'coderoad.run_test' ,
1919TEST_PASS :'coderoad.test_pass' ,
2020TEST_FAIL :'coderoad.test_fail' ,
21- SET_LAYOUT :'coderoad.set_layout' ,
2221}
2322
2423interface CreateCommandProps {
@@ -29,13 +28,21 @@ interface CreateCommandProps {
2928position :any
3029}
3130
31+ const resetLayout = ( ) => {
32+ vscode . commands . executeCommand ( 'vscode.setEditorLayout' , {
33+ orientation :0 ,
34+ groups :[ { groups :[ { } ] , size :0.6 } , { groups :[ { } ] , size :0.4 } ] ,
35+ } )
36+ }
37+
3238export const createCommands = ( { context, machine, storage, git, position} :CreateCommandProps ) => {
3339// React panel webview
3440let webview :any
3541
3642return {
3743// initialize
3844[ COMMANDS . START ] :( ) => {
45+
3946let webviewState :'INITIALIZING' | 'RESTARTING'
4047if ( ! webview ) {
4148webviewState = 'INITIALIZING'
@@ -64,10 +71,7 @@ export const createCommands = ({ context, machine, storage, git, position }: Cre
6471// open React webview
6572[ COMMANDS . OPEN_WEBVIEW ] :( column :number = vscode . ViewColumn . Two ) => {
6673// setup 1x1 horizontal layout
67- vscode . commands . executeCommand ( 'vscode.setEditorLayout' , {
68- orientation :0 ,
69- groups :[ { groups :[ { } ] , size :0.6 } , { groups :[ { } ] , size :0.4 } ] ,
70- } )
74+ resetLayout ( )
7175const callback = ( ) => {
7276machine . send ( 'WEBVIEW_INITIALIZED' )
7377}
@@ -118,6 +122,9 @@ export const createCommands = ({ context, machine, storage, git, position }: Cre
118122const absoluteFilePath = join ( workspaceRoot , relativeFilePath )
119123const doc = await vscode . workspace . openTextDocument ( absoluteFilePath )
120124await vscode . window . showTextDocument ( doc , vscode . ViewColumn . One )
125+ // there are times when intialization leave the panel behind any files opened
126+ // ensure the panel is redrawn on the right side first
127+ webview . createOrShow ( vscode . ViewColumn . Two )
121128} catch ( error ) {
122129console . log ( `Failed to open file${ relativeFilePath } ` , error )
123130}
@@ -145,12 +152,5 @@ export const createCommands = ({ context, machine, storage, git, position }: Cre
145152[ COMMANDS . TEST_FAIL ] :( ) => {
146153vscode . window . showWarningMessage ( 'FAIL' )
147154} ,
148- [ COMMANDS . SET_LAYOUT ] :( ) => {
149- console . log ( 'setLayout' )
150- vscode . commands . executeCommand ( 'vscode.setEditorLayout' , {
151- orientation :0 ,
152- groups :[ { groups :[ { } ] , size :0.6 } , { groups :[ { } ] , size :0.4 } ] ,
153- } )
154- } ,
155155}
156156}