Skip to content

Commit e9060db

Browse files
bors[bot]flodiebold
andcommitted
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]>
2 parents 5ebfd24 + d0811c4 commit e9060db

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)