diff options
author | James Leitch <[email protected]> | 2021-04-21 23:09:37 +0100 |
---|---|---|
committer | James Leitch <[email protected]> | 2021-04-21 23:10:53 +0100 |
commit | 72718bc2d7113874536b8bcd486aa5bd7dacafe6 (patch) | |
tree | c5859e4eb7334478b5e9ba58329b67df43e39305 /crates/rust-analyzer/src/diagnostics | |
parent | 9fcad829807a0306fbf4eb2ebc1603a11a6df182 (diff) |
Code review feedback.
Diffstat (limited to 'crates/rust-analyzer/src/diagnostics')
-rw-r--r-- | crates/rust-analyzer/src/diagnostics/to_proto.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index 08303a781..82dd0da9a 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs | |||
@@ -99,10 +99,12 @@ fn diagnostic_related_information( | |||
99 | /// Resolves paths applying any matching path prefix remappings, and then | 99 | /// Resolves paths applying any matching path prefix remappings, and then |
100 | /// joining the path to the workspace root. | 100 | /// joining the path to the workspace root. |
101 | fn resolve_path(config: &DiagnosticsMapConfig, workspace_root: &Path, file_name: &str) -> PathBuf { | 101 | fn resolve_path(config: &DiagnosticsMapConfig, workspace_root: &Path, file_name: &str) -> PathBuf { |
102 | match config.remap_path_prefixes.iter().find(|(from, _)| file_name.starts_with(*from)) { | 102 | match config |
103 | Some((from, to)) => { | 103 | .remap_prefix |
104 | workspace_root.join(format!("{}{}", to, file_name.strip_prefix(from).unwrap())) | 104 | .iter() |
105 | } | 105 | .find_map(|(from, to)| file_name.strip_prefix(from).map(|file_name| (to, file_name))) |
106 | { | ||
107 | Some((to, file_name)) => workspace_root.join(format!("{}{}", to, file_name)), | ||
106 | None => workspace_root.join(file_name), | 108 | None => workspace_root.join(file_name), |
107 | } | 109 | } |
108 | } | 110 | } |