aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-05 22:04:34 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-05 22:04:34 +0000
commite9060db1581a902f433ebe7df1f2c39c64e9bd36 (patch)
treed4616765e2f58978e486ed5c38f56ebd4be2b824 /crates
parent5ebfd24eb92f3b198c5b9df1b2d4fc58500ed788 (diff)
parentd0811c4066c90b03532860c93d2a14248240b2a0 (diff)
Merge #253
253: Fix diagnostic fixes showing up everywhere r=matklad a=flodiebold The LSP code action request always returned the fixes for all diagnostics anywhere in the file, because of a shadowed variable. There's no test yet; I wasn't sure where to add it. I tried adding one in `heavy_tests`, but that's a bit uncomfortable because the code action response contains the (random) file paths. I could make it work, but wanted to ask beforehand what you think. Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 6d5622b15..af21254e4 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -9,7 +9,7 @@ use languageserver_types::{
9 WorkspaceEdit, ParameterInformation, SignatureInformation, Hover, HoverContents, 9 WorkspaceEdit, ParameterInformation, SignatureInformation, Hover, HoverContents,
10}; 10};
11use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition}; 11use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition};
12use ra_syntax::{TextUnit, text_utils::contains_offset_nonstrict}; 12use ra_syntax::{TextUnit, text_utils::{contains_offset_nonstrict, intersect}};
13use rustc_hash::FxHashMap; 13use rustc_hash::FxHashMap;
14use serde_json::to_value; 14use serde_json::to_value;
15 15
@@ -618,7 +618,7 @@ pub fn handle_code_action(
618 .diagnostics(file_id)? 618 .diagnostics(file_id)?
619 .into_iter() 619 .into_iter()
620 .filter_map(|d| Some((d.range, d.fix?))) 620 .filter_map(|d| Some((d.range, d.fix?)))
621 .filter(|(range, _fix)| contains_offset_nonstrict(*range, range.start())) 621 .filter(|(diag_range, _fix)| intersect(*diag_range, range).is_some())
622 .map(|(_range, fix)| fix); 622 .map(|(_range, fix)| fix);
623 623
624 let mut res = Vec::new(); 624 let mut res = Vec::new();