Skip to content

Commit d0811c4

Browse files
committed
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.
1 parent 0bdf8de commit d0811c4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/ra_lsp_server/src/main_loop/handlers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use languageserver_types::{
99
WorkspaceEdit, ParameterInformation, SignatureInformation, Hover, HoverContents,
1010
};
1111
use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition};
12-
use ra_syntax::{TextUnit, text_utils::contains_offset_nonstrict};
12+
use ra_syntax::{TextUnit, text_utils::{contains_offset_nonstrict, intersect}};
1313
use rustc_hash::FxHashMap;
1414
use serde_json::to_value;
1515

@@ -618,7 +618,7 @@ pub fn handle_code_action(
618618
.diagnostics(file_id)?
619619
.into_iter()
620620
.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())
622622
.map(|(_range, fix)| fix);
623623

624624
let mut res = Vec::new();

0 commit comments

Comments
 (0)