File tree Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ impl CargoTargetSpec {
6363 None => return Ok ( None ) ,
6464 } ;
6565 let file_id = world. analysis ( ) . crate_root ( crate_id) ?;
66- let path = world. vfs . read ( ) . file2path ( ra_vfs :: VfsFile ( file_id. 0 ) ) ;
66+ let path = world. file_id_to_path ( file_id) ;
6767 let res = world. workspaces . iter ( ) . find_map ( |ws| match ws {
6868 ProjectWorkspace :: Cargo { cargo, .. } => {
6969 let tgt = cargo. target_by_root ( & path) ?;
Original file line number Diff line number Diff line change @@ -681,10 +681,12 @@ pub fn handle_code_action(
681681 continue ;
682682 }
683683
684- let edits = vec ! [ TextEdit :: new( fix. location. range, fix. replacement. clone( ) ) ] ;
685- let mut edit_map = std:: collections:: HashMap :: new ( ) ;
686- edit_map. insert ( fix. location . uri . clone ( ) , edits) ;
687- let edit = WorkspaceEdit :: new ( edit_map) ;
684+ let edit = {
685+ let edits = vec ! [ TextEdit :: new( fix. location. range, fix. replacement. clone( ) ) ] ;
686+ let mut edit_map = std:: collections:: HashMap :: new ( ) ;
687+ edit_map. insert ( fix. location . uri . clone ( ) , edits) ;
688+ WorkspaceEdit :: new ( edit_map)
689+ } ;
688690
689691 let action = CodeAction {
690692 title : fix. title . clone ( ) ,
Original file line number Diff line number Diff line change @@ -62,9 +62,9 @@ pub struct WorldSnapshot {
6262 pub options : Options ,
6363 pub workspaces : Arc < Vec < ProjectWorkspace > > ,
6464 pub analysis : Analysis ,
65- pub vfs : Arc < RwLock < Vfs > > ,
6665 pub latest_requests : Arc < RwLock < LatestRequests > > ,
6766 pub check_watcher : Arc < RwLock < CheckState > > ,
67+ vfs : Arc < RwLock < Vfs > > ,
6868}
6969
7070impl WorldState {
@@ -265,6 +265,10 @@ impl WorldSnapshot {
265265 Ok ( url)
266266 }
267267
268+ pub fn file_id_to_path ( & self , id : FileId ) -> PathBuf {
269+ self . vfs . read ( ) . file2path ( VfsFile ( id. 0 ) )
270+ }
271+
268272 pub fn file_line_endings ( & self , id : FileId ) -> LineEndings {
269273 self . vfs . read ( ) . file_line_endings ( VfsFile ( id. 0 ) )
270274 }
You can’t perform that action at this time.
0 commit comments