@@ -86,17 +86,13 @@ fn cvt_location_list_of_lists(
8686impl UniqueFileID {
8787 fn from_uri ( uri : & Url ) -> Result < UniqueFileID , String > {
8888 if uri. scheme ( ) == "file" {
89- UniqueFileID :: from_path ( & uri. to_file_path ( ) . unwrap ( ) )
89+ UniqueFileID :: from_path ( & uri. to_file_path ( ) . unwrap ( ) , uri . to_string ( ) )
9090 } else {
9191 Ok ( UniqueFileID :: from_non_path_str ( uri. to_string ( ) ) )
9292 }
9393 }
9494 fn to_uri ( & self ) -> Url {
95- if self . inode . is_some ( ) {
96- Url :: from_file_path ( & self . name ) . expect ( & self . name )
97- } else {
98- Url :: parse ( & self . name ) . expect ( & self . name )
99- }
95+ Url :: parse ( & self . name ) . expect ( & self . name )
10096 }
10197}
10298
@@ -218,6 +214,14 @@ fn initialize_all_files(linker: &mut Linker, init_params: &InitializeParams) {
218214 linker. add_file_or_directory ( f) ;
219215 }
220216 }
217+
218+ // Convert all the Path IDs to URIs
219+ for ( _, f) in & mut linker. files {
220+ f. file_identifier . name =
221+ Url :: from_file_path ( std:: fs:: canonicalize ( & f. file_identifier . name ) . unwrap ( ) )
222+ . expect ( & f. file_identifier . name )
223+ . to_string ( ) ;
224+ }
221225}
222226
223227fn gather_completions ( linker : & Linker , position : usize ) -> Vec < CompletionItem > {
@@ -562,11 +566,11 @@ fn handle_notification(
562566 linker. add_or_update_file_from_disk ( file_identifier) ;
563567 } else if event. typ == FileChangeType :: DELETED {
564568 let uri_as_string = event. uri . to_string ( ) ;
565- // Delete URIs that don't have a file backing
566- if let Some ( existing_file_id) = linker. files . find ( |_ , data| {
567- data . file_identifier . inode . is_none ( )
568- && data. file_identifier . name == uri_as_string
569- } ) {
569+ // Try to delete URIs (including those that that don't have a file backing)
570+ if let Some ( existing_file_id) = linker
571+ . files
572+ . find ( |_ , data| data. file_identifier . name == uri_as_string)
573+ {
570574 linker. remove_file ( existing_file_id) ;
571575 }
572576 } else {
@@ -577,7 +581,7 @@ fn handle_notification(
577581 let mut to_delete: Vec < FileUUID > = Vec :: new ( ) ;
578582 for ( id, f) in & linker. files {
579583 if f. file_identifier . inode . is_some ( ) {
580- match std:: fs:: exists ( & f. file_identifier . name ) {
584+ match std:: fs:: exists ( f. file_identifier . to_uri ( ) . path ( ) ) {
581585 Ok ( true ) => { }
582586 Ok ( false ) | Err ( _) => to_delete. push ( id) ,
583587 }
0 commit comments