From d0811c4066c90b03532860c93d2a14248240b2a0 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 2 Dec 2018 20:58:16 +0100 Subject: Fix diagnostic fixes showing up everywhere The LSP code action request always returned the fixes for all diagnostics anywhere in the file, because of a shadowed variable. --- crates/ra_lsp_server/src/main_loop/handlers.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_lsp_server/src') 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::{ WorkspaceEdit, ParameterInformation, SignatureInformation, Hover, HoverContents, }; use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition}; -use ra_syntax::{TextUnit, text_utils::contains_offset_nonstrict}; +use ra_syntax::{TextUnit, text_utils::{contains_offset_nonstrict, intersect}}; use rustc_hash::FxHashMap; use serde_json::to_value; @@ -618,7 +618,7 @@ pub fn handle_code_action( .diagnostics(file_id)? .into_iter() .filter_map(|d| Some((d.range, d.fix?))) - .filter(|(range, _fix)| contains_offset_nonstrict(*range, range.start())) + .filter(|(diag_range, _fix)| intersect(*diag_range, range).is_some()) .map(|(_range, fix)| fix); let mut res = Vec::new(); -- cgit v1.2.3