@@ -20,43 +20,61 @@ function stopReloadUI() {
20
20
removeElementsByClass ( "msgbox-overlay" )
21
21
}
22
22
23
- let tty
24
- window . addEventListener ( "ide-ready" , ( ) => {
25
- window . ide . workbench . onFileSaved ( ( ev ) => {
26
- if ( ! ev . endsWith ( ".sail/Dockerfile" ) ) {
27
- return
28
- }
23
+ function rebuild ( ) {
24
+ const tsrv = window . ide . workbench . terminalService
29
25
30
- const srv = window . ide . workbench . terminalService
26
+ if ( tty == null ) {
27
+ tty = tsrv . createTerminal ( {
28
+ name : "sail" ,
29
+ isRendererOnly : true ,
30
+ } , false )
31
+ } else {
32
+ tty . clear ( )
33
+ }
34
+ let oldTTY = tsrv . getActiveInstance ( )
35
+ tsrv . setActiveInstance ( tty )
36
+ // Show the panel and focus it to prevent the user from editing the Dockerfile.
37
+ tsrv . showPanel ( true )
31
38
32
- if ( tty == null ) {
33
- tty = srv . createTerminal ( {
34
- name : "sail" ,
35
- isRendererOnly : true ,
36
- } , false )
39
+ startReloadUI ( )
40
+
41
+ const ws = new WebSocket ( "ws://" + location . host + "/sail/api/v1/reload" )
42
+ ws . onmessage = ( ev ) => {
43
+ const msg = JSON . parse ( ev . data )
44
+ const out = atob ( msg . v ) . replace ( / \n / g, "\n\r" )
45
+ tty . write ( out )
46
+ }
47
+ ws . onclose = ( ev ) => {
48
+ if ( ev . code === 1000 ) {
49
+ tsrv . setActiveInstance ( oldTTY )
37
50
} else {
38
- tty . clear ( )
39
- }
40
- let oldTTY = srv . getActiveInstance ( )
41
- srv . setActiveInstance ( tty )
42
- // Show the panel and focus it to prevent the user from editing the Dockerfile.
43
- srv . showPanel ( true )
44
-
45
- startReloadUI ( )
46
-
47
- const ws = new WebSocket ( "ws://" + location . host + "/sail/api/v1/reload" )
48
- ws . onmessage = ( ev ) => {
49
- const msg = JSON . parse ( ev . data )
50
- const out = atob ( msg . v ) . replace ( / \n / g, "\n\r" )
51
- tty . write ( out )
51
+ alert ( "reload failed; please see logs in sail terminal" )
52
52
}
53
- ws . onclose = ( ev ) => {
54
- if ( ev . code === 1000 ) {
55
- srv . setActiveInstance ( oldTTY )
56
- } else {
57
- alert ( "reload failed; please see logs in sail terminal" )
58
- }
59
- stopReloadUI ( )
53
+ stopReloadUI ( )
54
+ }
55
+ }
56
+
57
+ let tty
58
+ window . addEventListener ( "ide-ready" , ( ) => {
59
+ const statusBarService = window . ide . workbench . statusbarService
60
+ statusBarService . addEntry ( {
61
+ text : "rebuild" ,
62
+ tooltip : "press super+alt+r to rebuild" ,
63
+ command : "rebuild-sail-container"
64
+ // showBeak: true <- what does this do?
65
+ } , 0 )
66
+
67
+ const commandRegistry = window . ide . workbench . commandRegistry
68
+ commandRegistry . registerCommand ( {
69
+ id : "rebuild-sail-container" ,
70
+ handler : ( accessor , args ) => {
71
+ rebuild ( )
72
+ } ,
73
+ description : {
74
+ description : "Rebuild sail container" ,
75
+ args : [ ]
60
76
}
61
77
} )
78
+
79
+ const
62
80
} )
0 commit comments