mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 02:37:21 +00:00
Properly binary search cached inlay hints
This commit is contained in:
parent
3c55c933d4
commit
abd2d012b1
1 changed files with 28 additions and 10 deletions
|
@ -714,13 +714,21 @@ fn calculate_hint_updates(
|
||||||
probe.1.position.cmp(&new_hint.position, buffer_snapshot)
|
probe.1.position.cmp(&new_hint.position, buffer_snapshot)
|
||||||
}) {
|
}) {
|
||||||
Ok(ix) => {
|
Ok(ix) => {
|
||||||
let (cached_inlay_id, cached_hint) = &cached_excerpt_hints.hints[ix];
|
let mut missing_from_cache = true;
|
||||||
if cached_hint == &new_hint {
|
for (cached_inlay_id, cached_hint) in &cached_excerpt_hints.hints[ix..] {
|
||||||
excerpt_hints_to_persist.insert(*cached_inlay_id, cached_hint.kind);
|
if new_hint
|
||||||
false
|
.position
|
||||||
} else {
|
.cmp(&cached_hint.position, buffer_snapshot)
|
||||||
true
|
.is_gt()
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if cached_hint == &new_hint {
|
||||||
|
excerpt_hints_to_persist.insert(*cached_inlay_id, cached_hint.kind);
|
||||||
|
missing_from_cache = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
missing_from_cache
|
||||||
}
|
}
|
||||||
Err(_) => true,
|
Err(_) => true,
|
||||||
}
|
}
|
||||||
|
@ -820,11 +828,21 @@ fn apply_hint_update(
|
||||||
.binary_search_by(|probe| probe.1.position.cmp(&new_hint.position, &buffer_snapshot))
|
.binary_search_by(|probe| probe.1.position.cmp(&new_hint.position, &buffer_snapshot))
|
||||||
{
|
{
|
||||||
Ok(i) => {
|
Ok(i) => {
|
||||||
if cached_hints[i].1.text() == new_hint.text() {
|
let mut insert_position = Some(i);
|
||||||
None
|
for (_, cached_hint) in &cached_hints[i..] {
|
||||||
} else {
|
if new_hint
|
||||||
Some(i)
|
.position
|
||||||
|
.cmp(&cached_hint.position, &buffer_snapshot)
|
||||||
|
.is_gt()
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if cached_hint.text() == new_hint.text() {
|
||||||
|
insert_position = None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
insert_position
|
||||||
}
|
}
|
||||||
Err(i) => Some(i),
|
Err(i) => Some(i),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue