@@ -392,7 +392,26 @@ impl LanguageServer for ProtoLanguageServer {
392392 Box :: pin ( async move { Ok ( response) } )
393393 }
394394
395- fn did_save ( & mut self , _: DidSaveTextDocumentParams ) -> Self :: NotifyResult {
395+ fn did_save ( & mut self , params : DidSaveTextDocumentParams ) -> Self :: NotifyResult {
396+ let uri = params. text_document . uri ;
397+ let content = self . state . get_content ( & uri) ;
398+
399+ let Some ( ipath) = self . configs . get_include_paths ( & uri) else {
400+ return ControlFlow :: Continue ( ( ) ) ;
401+ } ;
402+
403+ let Some ( pconf) = self . configs . get_config_for_uri ( & uri) else {
404+ return ControlFlow :: Continue ( ( ) ) ;
405+ } ;
406+
407+ if let Some ( diagnostics) = self
408+ . state
409+ . upsert_file ( & uri, content, & ipath, 8 , & pconf. config )
410+ {
411+ if let Err ( e) = self . client . publish_diagnostics ( diagnostics) {
412+ error ! ( error=%e, "failed to publish diagnostics" )
413+ }
414+ }
396415 ControlFlow :: Continue ( ( ) )
397416 }
398417
@@ -408,15 +427,14 @@ impl LanguageServer for ProtoLanguageServer {
408427 return ControlFlow :: Continue ( ( ) ) ;
409428 } ;
410429
411- let Some ( diagnostics) = self . state . upsert_file ( & uri, content. clone ( ) , & ipath, 8 ) else {
412- return ControlFlow :: Continue ( ( ) ) ;
413- } ;
414-
415430 let Some ( pconf) = self . configs . get_config_for_uri ( & uri) else {
416431 return ControlFlow :: Continue ( ( ) ) ;
417432 } ;
418433
419- if !pconf. config . disable_parse_diagnostics {
434+ if let Some ( diagnostics) = self
435+ . state
436+ . upsert_file ( & uri, content, & ipath, 8 , & pconf. config )
437+ {
420438 if let Err ( e) = self . client . publish_diagnostics ( diagnostics) {
421439 error ! ( error=%e, "failed to publish diagnostics" )
422440 }
@@ -432,20 +450,18 @@ impl LanguageServer for ProtoLanguageServer {
432450 return ControlFlow :: Continue ( ( ) ) ;
433451 } ;
434452
435- let Some ( diagnostics) = self . state . upsert_file ( & uri, content, & ipath, 2 ) else {
436- return ControlFlow :: Continue ( ( ) ) ;
437- } ;
438-
439- let Some ( ws) = self . configs . get_config_for_uri ( & uri) else {
453+ let Some ( pconf) = self . configs . get_config_for_uri ( & uri) else {
440454 return ControlFlow :: Continue ( ( ) ) ;
441455 } ;
442456
443- if !ws. config . disable_parse_diagnostics {
457+ // override config to disable protoc diagnostics during change
458+ let mut pconf = pconf. config . clone ( ) ;
459+ pconf. experimental . use_protoc_diagnostics = false ;
460+ if let Some ( diagnostics) = self . state . upsert_file ( & uri, content, & ipath, 8 , & pconf) {
444461 if let Err ( e) = self . client . publish_diagnostics ( diagnostics) {
445462 error ! ( error=%e, "failed to publish diagnostics" )
446463 }
447464 }
448-
449465 ControlFlow :: Continue ( ( ) )
450466 }
451467
0 commit comments