History

editor: Make hover popover delay strictly respect hover_popover_delay setting (#41149)

Previously, the hover popover delay was implemented using two overlapping timers, which caused the minimum delay to always be at least HOVER_REQUEST_DELAY_MILLIS, regardless of the hover_popover_delay setting. This change updates the logic to wait for hover_popover_delay only, ensuring the total delay is always equals to hover_popover_delay . As a result, the hover popover now appears after the intended delay, matching the user's configuration more accurately. Release Notes: - Improved hover popover respecting settings delay correctly

deltamaya committed 1 year ago

Commit edf2ec71 parent 2919e191 file · +8 −7Browse files

Unified · Split

crates/editor/src/hover_popover.rs+8−7
@@ -27,7 +27,6 @@ use ui::{Scrollbars, WithScrollbar, prelude::*, theme_is_transparent}; · 26 unmodified lines
2727 use url::Url;
2828 use util::TryFutureExt;
2929 use workspace::{OpenOptions, OpenVisible, Workspace};
30−pub const HOVER_REQUEST_DELAY_MILLIS: u64 = 200;
3130
3231 pub const MIN_POPOVER_CHARACTER_WIDTH: f32 = 20.;
3332 pub const MIN_POPOVER_LINE_HEIGHT: f32 = 4.;
@@ -290,15 +289,18 @@ fn show_hover( · 256 unmodified lines
290289 let delay = if ignore_timeout {
291290 None
292291 } else {
292+ let lsp_request_early = hover_popover_delay / 2;
293+ cx.background_executor()
294+ .timer(Duration::from_millis(
295+ hover_popover_delay - lsp_request_early,
296+ ))
297+ .await;
298+
293299 // Construct delay task to wait for later
294300 let total_delay = Some(
295301 cx.background_executor()
296− .timer(Duration::from_millis(hover_popover_delay)),
302+ .timer(Duration::from_millis(lsp_request_early)),
297303 );
298−
299− cx.background_executor()
300− .timer(Duration::from_millis(HOVER_REQUEST_DELAY_MILLIS))
301− .await;
302304 total_delay
303305 };
304306
@@ -307,7 +309,6 @@ fn show_hover( · 2 unmodified lines
307309 if let Some(delay) = delay {
308310 delay.await;
309311 }
310−
311312 let offset = anchor.to_offset(&snapshot.buffer_snapshot());
312313 let local_diagnostic = if all_diagnostics_active {
313314 None