lsp colors: Reduce flickering while typing (#40055)

Closes #40019

Follow-up https://github.com/zed-industries/zed/pull/40025

This PR reduces/removes the flickering of inlay colors. This is done by
adding a debounce, and not detaching the task that fetches the new
colors.

**Result**


https://github.com/user-attachments/assets/5dae278b-b821-4e64-8adb-c4d8376ba1df

Release Notes:

- Lsp colors: Reduce flickering while typing.

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
This commit is contained in:
Remco Smits
2025-10-12 18:59:12 +00:00
committed by GitHub
co-authored by Kirill Bulatov
parent 83f0a36733
commit 3f3d894c8b
4 changed files with 23 additions and 14 deletions
+3
View File
@@ -226,6 +226,7 @@ pub const SELECTION_HIGHLIGHT_DEBOUNCE_TIMEOUT: Duration = Duration::from_millis
pub(crate) const CODE_ACTION_TIMEOUT: Duration = Duration::from_secs(5);
pub(crate) const FORMAT_TIMEOUT: Duration = Duration::from_secs(5);
pub(crate) const SCROLL_CENTER_TOP_BOTTOM_DEBOUNCE_TIMEOUT: Duration = Duration::from_secs(1);
pub const FETCH_COLORS_DEBOUNCE_TIMEOUT: Duration = Duration::from_millis(150);
pub(crate) const EDIT_PREDICTION_KEY_CONTEXT: &str = "edit_prediction";
pub(crate) const EDIT_PREDICTION_CONFLICT_KEY_CONTEXT: &str = "edit_prediction_conflict";
@@ -1189,6 +1190,7 @@ pub struct Editor {
inline_value_cache: InlineValueCache,
selection_drag_state: SelectionDragState,
colors: Option<LspColorData>,
refresh_colors_task: Task<()>,
folding_newlines: Task<()>,
pub lookup_key: Option<Box<dyn Any + Send + Sync>>,
}
@@ -2244,6 +2246,7 @@ impl Editor {
tasks_update_task: None,
pull_diagnostics_task: Task::ready(()),
colors: None,
refresh_colors_task: Task::ready(()),
next_color_inlay_id: 0,
linked_edit_ranges: Default::default(),
in_project_search: false,