Add basic debounce, fix flickering

This commit is contained in:
Isaac Clayton 2022-05-31 17:57:51 +02:00 committed by Keith Simmons
parent 560dff7329
commit d529a1deb4
4 changed files with 142 additions and 57 deletions

View file

@ -1,4 +1,4 @@
use crate::{DocumentHighlight, Location, Project, ProjectTransaction, Hover};
use crate::{DocumentHighlight, Hover, Location, Project, ProjectTransaction};
use anyhow::{anyhow, Result};
use async_trait::async_trait;
use client::{proto, PeerId};
@ -828,18 +828,16 @@ impl LspCommand for GetHover {
let range = hover.range.map(|range| {
cx.read(|cx| {
let buffer = buffer.read(cx);
let token_start = buffer
.clip_point_utf16(point_from_lsp(range.start), Bias::Left);
let token_end = buffer
.clip_point_utf16(point_from_lsp(range.end), Bias::Left);
buffer.anchor_after(token_start)..
buffer.anchor_before(token_end)
let token_start =
buffer.clip_point_utf16(point_from_lsp(range.start), Bias::Left);
let token_end = buffer.clip_point_utf16(point_from_lsp(range.end), Bias::Left);
buffer.anchor_after(token_start)..buffer.anchor_before(token_end)
})
});
Hover {
contents: hover.contents,
range
range,
}
}))
}