mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-21 03:18:47 +03:00
Properly omit throttled hint queries
This commit is contained in:
parent
851d74d5e1
commit
73937876b6
@ -877,33 +877,33 @@ async fn fetch_and_update_hints(
|
|||||||
let inlay_hints_fetch_task = editor
|
let inlay_hints_fetch_task = editor
|
||||||
.update(&mut cx, |editor, cx| {
|
.update(&mut cx, |editor, cx| {
|
||||||
if got_throttled {
|
if got_throttled {
|
||||||
if let Some((_, _, current_visible_range)) = editor
|
let query_not_around_visible_range = match editor.excerpt_visible_offsets(None, cx).remove(&query.excerpt_id) {
|
||||||
.excerpt_visible_offsets(None, cx)
|
Some((_, _, current_visible_range)) => {
|
||||||
.remove(&query.excerpt_id)
|
let visible_offset_length = current_visible_range.len();
|
||||||
{
|
let double_visible_range = current_visible_range
|
||||||
let visible_offset_length = current_visible_range.len();
|
.start
|
||||||
let double_visible_range = current_visible_range
|
.saturating_sub(visible_offset_length)
|
||||||
.start
|
..current_visible_range
|
||||||
.saturating_sub(visible_offset_length)
|
.end
|
||||||
..current_visible_range
|
.saturating_add(visible_offset_length)
|
||||||
.end
|
.min(buffer_snapshot.len());
|
||||||
.saturating_add(visible_offset_length)
|
!double_visible_range
|
||||||
.min(buffer_snapshot.len());
|
.contains(&fetch_range.start.to_offset(&buffer_snapshot))
|
||||||
if !double_visible_range
|
&& !double_visible_range
|
||||||
.contains(&fetch_range.start.to_offset(&buffer_snapshot))
|
.contains(&fetch_range.end.to_offset(&buffer_snapshot))
|
||||||
&& !double_visible_range
|
},
|
||||||
.contains(&fetch_range.end.to_offset(&buffer_snapshot))
|
None => true,
|
||||||
|
};
|
||||||
|
if query_not_around_visible_range {
|
||||||
|
log::trace!("Fetching inlay hints for range {fetch_range_to_log:?} got throttled and fell off the current visible range, skipping.");
|
||||||
|
if let Some(task_ranges) = editor
|
||||||
|
.inlay_hint_cache
|
||||||
|
.update_tasks
|
||||||
|
.get_mut(&query.excerpt_id)
|
||||||
{
|
{
|
||||||
log::trace!("Fetching inlay hints for range {fetch_range_to_log:?} got throttled and fell off the current visible range, skipping.");
|
task_ranges.remove_from_cached_ranges(&buffer_snapshot, &fetch_range);
|
||||||
if let Some(task_ranges) = editor
|
|
||||||
.inlay_hint_cache
|
|
||||||
.update_tasks
|
|
||||||
.get_mut(&query.excerpt_id)
|
|
||||||
{
|
|
||||||
task_ranges.remove_from_cached_ranges(&buffer_snapshot, &fetch_range);
|
|
||||||
}
|
|
||||||
return None;
|
|
||||||
}
|
}
|
||||||
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
editor
|
editor
|
||||||
|
Loading…
Reference in New Issue
Block a user