diff options
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r-- | crates/ra_lsp_server/src/cargo_target_spec.rs | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 10 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/world.rs | 6 |
3 files changed, 12 insertions, 6 deletions
diff --git a/crates/ra_lsp_server/src/cargo_target_spec.rs b/crates/ra_lsp_server/src/cargo_target_spec.rs index c4a9e7101..594caffe2 100644 --- a/crates/ra_lsp_server/src/cargo_target_spec.rs +++ b/crates/ra_lsp_server/src/cargo_target_spec.rs | |||
@@ -63,7 +63,7 @@ impl CargoTargetSpec { | |||
63 | None => return Ok(None), | 63 | None => return Ok(None), |
64 | }; | 64 | }; |
65 | let file_id = world.analysis().crate_root(crate_id)?; | 65 | 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); |
67 | let res = world.workspaces.iter().find_map(|ws| match ws { | 67 | let res = world.workspaces.iter().find_map(|ws| match ws { |
68 | ProjectWorkspace::Cargo { cargo, .. } => { | 68 | ProjectWorkspace::Cargo { cargo, .. } => { |
69 | let tgt = cargo.target_by_root(&path)?; | 69 | let tgt = cargo.target_by_root(&path)?; |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 9e9964880..8e43f0575 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -681,10 +681,12 @@ pub fn handle_code_action( | |||
681 | continue; | 681 | continue; |
682 | } | 682 | } |
683 | 683 | ||
684 | let edits = vec![TextEdit::new(fix.location.range, fix.replacement.clone())]; | 684 | let edit = { |
685 | let mut edit_map = std::collections::HashMap::new(); | 685 | let edits = vec![TextEdit::new(fix.location.range, fix.replacement.clone())]; |
686 | edit_map.insert(fix.location.uri.clone(), edits); | 686 | let mut edit_map = std::collections::HashMap::new(); |
687 | let edit = WorkspaceEdit::new(edit_map); | 687 | edit_map.insert(fix.location.uri.clone(), edits); |
688 | WorkspaceEdit::new(edit_map) | ||
689 | }; | ||
688 | 690 | ||
689 | let action = CodeAction { | 691 | let action = CodeAction { |
690 | title: fix.title.clone(), | 692 | title: fix.title.clone(), |
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 7a3030a51..e7a0acfc7 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs | |||
@@ -62,9 +62,9 @@ pub struct WorldSnapshot { | |||
62 | pub options: Options, | 62 | pub options: Options, |
63 | pub workspaces: Arc<Vec<ProjectWorkspace>>, | 63 | pub workspaces: Arc<Vec<ProjectWorkspace>>, |
64 | pub analysis: Analysis, | 64 | pub analysis: Analysis, |
65 | pub vfs: Arc<RwLock<Vfs>>, | ||
66 | pub latest_requests: Arc<RwLock<LatestRequests>>, | 65 | pub latest_requests: Arc<RwLock<LatestRequests>>, |
67 | pub check_watcher: Arc<RwLock<CheckState>>, | 66 | pub check_watcher: Arc<RwLock<CheckState>>, |
67 | vfs: Arc<RwLock<Vfs>>, | ||
68 | } | 68 | } |
69 | 69 | ||
70 | impl WorldState { | 70 | impl WorldState { |
@@ -265,6 +265,10 @@ impl WorldSnapshot { | |||
265 | Ok(url) | 265 | Ok(url) |
266 | } | 266 | } |
267 | 267 | ||
268 | pub fn file_id_to_path(&self, id: FileId) -> PathBuf { | ||
269 | self.vfs.read().file2path(VfsFile(id.0)) | ||
270 | } | ||
271 | |||
268 | pub fn file_line_endings(&self, id: FileId) -> LineEndings { | 272 | pub fn file_line_endings(&self, id: FileId) -> LineEndings { |
269 | self.vfs.read().file_line_endings(VfsFile(id.0)) | 273 | self.vfs.read().file_line_endings(VfsFile(id.0)) |
270 | } | 274 | } |