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) {
122122 context . subscriptions . push ( disposable ) ;
123123 } ) ;
124124
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+
125132 context . subscriptions . push (
126133 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 ) ;
132135 } )
133136 ) ;
134137
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+
135148 function getLS ( ) {
136149 return ls ;
137150 }
You can’t perform that action at this time.
0 commit comments