File tree 3 files changed +11
-0
lines changed
3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -489,6 +489,10 @@ impl GlobalStateSnapshot {
489
489
pub ( crate ) fn vfs_memory_usage ( & self ) -> usize {
490
490
self . vfs . read ( ) . 0 . memory_usage ( )
491
491
}
492
+
493
+ pub ( crate ) fn file_exists ( & self , file_id : FileId ) -> bool {
494
+ self . vfs . read ( ) . 0 . exists ( file_id)
495
+ }
492
496
}
493
497
494
498
pub ( crate ) fn file_id_to_url ( vfs : & vfs:: Vfs , id : FileId ) -> Url {
Original file line number Diff line number Diff line change @@ -1438,6 +1438,8 @@ pub(crate) fn handle_inlay_hints_resolve(
1438
1438
1439
1439
let resolve_data: lsp_ext:: InlayHintResolveData = serde_json:: from_value ( data) ?;
1440
1440
let file_id = FileId ( resolve_data. file_id ) ;
1441
+ anyhow:: ensure!( snap. file_exists( file_id) , "Invalid LSP resolve data" ) ;
1442
+
1441
1443
let line_index = snap. file_line_index ( file_id) ?;
1442
1444
let range = from_proto:: text_range (
1443
1445
& line_index,
Original file line number Diff line number Diff line change @@ -184,6 +184,11 @@ impl Vfs {
184
184
mem:: take ( & mut self . changes )
185
185
}
186
186
187
+ /// Provides a panic-less way to verify file_id validity.
188
+ pub fn exists ( & self , file_id : FileId ) -> bool {
189
+ self . get ( file_id) . is_some ( )
190
+ }
191
+
187
192
/// Returns the id associated with `path`
188
193
///
189
194
/// - If `path` does not exists in the `Vfs`, allocate a new id for it, associated with a
You can’t perform that action at this time.
0 commit comments