Merge #10902
10902: Handle multiple cargo check quick fix spans r=Veykril a=brandondong Resolves https://github.com/rust-analyzer/rust-analyzer/issues/10705. **Cause:** - For a cargo check diagnostic with multiple spans, only a single quick fix action would be created at the location of `spans[0]`. Additionally, the hover window details would only show the location of `spans[0]` next to the message. **Fix:** - Allow cargo check quick fix actions to be triggerable from multiple selection ranges. Specifically, if the selection intersects with any of the replacement spans, the quick fix action is shown. - No change in behavior for the hover window details. It's pretty minor and I think showing multiple locations next to the message may be more confusing anyways. Co-authored-by: Brandon <brandondong604@hotmail.com>
This commit is contained in:
@@ -1081,8 +1081,13 @@ pub(crate) fn handle_code_action(
|
||||
for fix in snap.check_fixes.get(&frange.file_id).into_iter().flatten() {
|
||||
// FIXME: this mapping is awkward and shouldn't exist. Refactor
|
||||
// `snap.check_fixes` to not convert to LSP prematurely.
|
||||
let fix_range = from_proto::text_range(&line_index, fix.range);
|
||||
if fix_range.intersect(frange.range).is_some() {
|
||||
let intersect_fix_range = fix
|
||||
.ranges
|
||||
.iter()
|
||||
.copied()
|
||||
.map(|range| from_proto::text_range(&line_index, range))
|
||||
.any(|fix_range| fix_range.intersect(frange.range).is_some());
|
||||
if intersect_fix_range {
|
||||
res.push(fix.action.clone());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user