editor: Add debounce setting for triggering DocumentHighlight (#21702)
Closes https://github.com/zed-industries/zed/issues/6843 I don't see where is the logic to remove old document highlight when new one applies, ideally, old highlight should be cleared as soon as possible when cursor moves if the new position does not sits in old highlight ranges to avoid linger highlights described in https://github.com/zed-industries/zed/issues/13682#issuecomment-2498368680. So current solution is still not ideal, because only when lsp responses highlight ranges (even is a empty set) can we clear the old one. Release Notes: - Added a setting `lsp_highlight_debounce` to configure delay for querying highlights from language server. --------- Co-authored-by: mgsloan@gmail.com <michael@zed.dev>
This commit is contained in:
parent
57874717c1
commit
8dd1c23b92
4 changed files with 17 additions and 4 deletions
|
@ -190,8 +190,6 @@ const MAX_SELECTION_HISTORY_LEN: usize = 1024;
|
|||
pub(crate) const CURSORS_VISIBLE_FOR: Duration = Duration::from_millis(2000);
|
||||
#[doc(hidden)]
|
||||
pub const CODE_ACTIONS_DEBOUNCE_TIMEOUT: Duration = Duration::from_millis(250);
|
||||
#[doc(hidden)]
|
||||
pub const DOCUMENT_HIGHLIGHTS_DEBOUNCE_TIMEOUT: Duration = Duration::from_millis(75);
|
||||
|
||||
pub(crate) const FORMAT_TIMEOUT: Duration = Duration::from_secs(2);
|
||||
pub(crate) const SCROLL_CENTER_TOP_BOTTOM_DEBOUNCE_TIMEOUT: Duration = Duration::from_secs(1);
|
||||
|
@ -4311,10 +4309,10 @@ impl Editor {
|
|||
if cursor_buffer != tail_buffer {
|
||||
return None;
|
||||
}
|
||||
|
||||
let debounce = EditorSettings::get_global(cx).lsp_highlight_debounce;
|
||||
self.document_highlights_task = Some(cx.spawn(|this, mut cx| async move {
|
||||
cx.background_executor()
|
||||
.timer(DOCUMENT_HIGHLIGHTS_DEBOUNCE_TIMEOUT)
|
||||
.timer(Duration::from_millis(debounce))
|
||||
.await;
|
||||
|
||||
let highlights = if let Some(highlights) = cx
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue