@@ -292,11 +292,17 @@ impl ServerConnection {
292292 ) ) ;
293293 }
294294
295- fn publish_diagnostics ( & self , diags : SmallMap < PathBuf , Vec < Diagnostic > > ) {
295+ fn publish_diagnostics (
296+ & self ,
297+ diags : SmallMap < PathBuf , Vec < Diagnostic > > ,
298+ version_info : & HashMap < PathBuf , i32 > ,
299+ ) {
296300 for ( path, diags) in diags {
297301 let path = std:: fs:: canonicalize ( & path) . unwrap_or ( path) ;
298302 match Url :: from_file_path ( & path) {
299- Ok ( uri) => self . publish_diagnostics_for_uri ( uri, diags, None ) ,
303+ Ok ( uri) => {
304+ self . publish_diagnostics_for_uri ( uri, diags, version_info. get ( & path) . copied ( ) )
305+ }
300306 Err ( _) => eprint ! ( "Unable to convert path to uri: {path:?}" ) ,
301307 }
302308 }
@@ -1218,7 +1224,8 @@ impl Server {
12181224 let handle = make_open_handle ( & self . state , path) ;
12191225 Self :: append_unreachable_diagnostics ( transaction, & handle, diagnostics) ;
12201226 }
1221- self . connection . publish_diagnostics ( diags) ;
1227+ self . connection
1228+ . publish_diagnostics ( diags, & * self . version_info . lock ( ) ) ;
12221229 } ;
12231230
12241231 match possibly_committable_transaction {
@@ -1570,6 +1577,7 @@ impl Server {
15701577 self . version_info . lock ( ) . remove ( & uri) ;
15711578 let open_files = self . open_files . dupe ( ) ;
15721579 open_files. write ( ) . remove ( & uri) ;
1580+ // TODO: should we use the last version or None?
15731581 self . connection
15741582 . publish_diagnostics_for_uri ( params. text_document . uri , Vec :: new ( ) , None ) ;
15751583 let state = self . state . dupe ( ) ;
0 commit comments