Editor: Do not display code actions in task gutter menu if they belong to different line (#11506)
This doesn't address the focus issues we saw with @maxbrunsfeld yet. Release Notes: - N/A
This commit is contained in:
parent
47c12c6563
commit
07942bbdfe
1 changed files with 24 additions and 4 deletions
|
@ -458,7 +458,7 @@ pub struct Editor {
|
||||||
find_all_references_task_sources: Vec<Anchor>,
|
find_all_references_task_sources: Vec<Anchor>,
|
||||||
next_completion_id: CompletionId,
|
next_completion_id: CompletionId,
|
||||||
completion_documentation_pre_resolve_debounce: DebouncedDelay,
|
completion_documentation_pre_resolve_debounce: DebouncedDelay,
|
||||||
available_code_actions: Option<(Model<Buffer>, Arc<[CodeAction]>)>,
|
available_code_actions: Option<(Location, Arc<[CodeAction]>)>,
|
||||||
code_actions_task: Option<Task<()>>,
|
code_actions_task: Option<Task<()>>,
|
||||||
document_highlights_task: Option<Task<()>>,
|
document_highlights_task: Option<Task<()>>,
|
||||||
pending_rename: Option<RenameState>,
|
pending_rename: Option<RenameState>,
|
||||||
|
@ -3867,11 +3867,25 @@ impl Editor {
|
||||||
.buffer_line_for_row(buffer_point.row)
|
.buffer_line_for_row(buffer_point.row)
|
||||||
.map(|(_, Range { start, .. })| start);
|
.map(|(_, Range { start, .. })| start);
|
||||||
let tasks = this.tasks.get(&display_row).map(|t| Arc::new(t.to_owned()));
|
let tasks = this.tasks.get(&display_row).map(|t| Arc::new(t.to_owned()));
|
||||||
let (buffer, code_actions) = this.available_code_actions.clone().unzip();
|
let (location, code_actions) = this
|
||||||
|
.available_code_actions
|
||||||
|
.clone()
|
||||||
|
.and_then(|(location, code_actions)| {
|
||||||
|
let snapshot = location.buffer.read(cx).snapshot();
|
||||||
|
let point_range = location.range.to_point(&snapshot);
|
||||||
|
let point_range = point_range.start.row..=point_range.end.row;
|
||||||
|
if buffer_row.map_or(false, |row| point_range.contains(&row.row)) {
|
||||||
|
Some((location, code_actions))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.unzip();
|
||||||
if tasks.is_none() && code_actions.is_none() {
|
if tasks.is_none() && code_actions.is_none() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let buffer = buffer.or_else(|| {
|
|
||||||
|
let buffer = location.map(|location| location.buffer).or_else(|| {
|
||||||
let snapshot = this.snapshot(cx);
|
let snapshot = this.snapshot(cx);
|
||||||
let (buffer_snapshot, _) =
|
let (buffer_snapshot, _) =
|
||||||
snapshot.buffer_snapshot.buffer_line_for_row(display_row)?;
|
snapshot.buffer_snapshot.buffer_line_for_row(display_row)?;
|
||||||
|
@ -4124,7 +4138,13 @@ impl Editor {
|
||||||
this.available_code_actions = if actions.is_empty() {
|
this.available_code_actions = if actions.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some((start_buffer, actions.into()))
|
Some((
|
||||||
|
Location {
|
||||||
|
buffer: start_buffer,
|
||||||
|
range: start..end,
|
||||||
|
},
|
||||||
|
actions.into(),
|
||||||
|
))
|
||||||
};
|
};
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue