File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
packages/svelte-vscode/src Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -122,16 +122,29 @@ export function activate(context: ExtensionContext) {
122
122
context . subscriptions . push ( disposable ) ;
123
123
} ) ;
124
124
125
+ workspace . onDidSaveTextDocument ( async ( doc ) => {
126
+ const parts = doc . uri . toString ( ) . split ( / \/ | \\ / ) ;
127
+ if ( [ 'tsconfig.json' , 'jsconfig.json' ] . includes ( parts [ parts . length - 1 ] ) ) {
128
+ await restartLS ( false ) ;
129
+ }
130
+ } ) ;
131
+
125
132
context . subscriptions . push (
126
133
commands . registerCommand ( 'svelte.restartLanguageServer' , async ( ) => {
127
- await ls . stop ( ) ;
128
- ls = createLanguageServer ( serverOptions , clientOptions ) ;
129
- context . subscriptions . push ( ls . start ( ) ) ;
130
- await ls . onReady ( ) ;
131
- window . showInformationMessage ( 'Svelte language server restarted.' ) ;
134
+ await restartLS ( true ) ;
132
135
} )
133
136
) ;
134
137
138
+ async function restartLS ( showNotification : boolean ) {
139
+ await ls . stop ( ) ;
140
+ ls = createLanguageServer ( serverOptions , clientOptions ) ;
141
+ context . subscriptions . push ( ls . start ( ) ) ;
142
+ await ls . onReady ( ) ;
143
+ if ( showNotification ) {
144
+ window . showInformationMessage ( 'Svelte language server restarted.' ) ;
145
+ }
146
+ }
147
+
135
148
function getLS ( ) {
136
149
return ls ;
137
150
}
You can’t perform that action at this time.
0 commit comments