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
27use url::Url;27use url::Url;
28use util::TryFutureExt;28use util::TryFutureExt;
29use workspace::{OpenOptions, OpenVisible, Workspace};29use workspace::{OpenOptions, OpenVisible, Workspace};
30pub const HOVER_REQUEST_DELAY_MILLIS: u64 = 200;
31 30
32pub const MIN_POPOVER_CHARACTER_WIDTH: f32 = 20.;31pub const MIN_POPOVER_CHARACTER_WIDTH: f32 = 20.;
33pub const MIN_POPOVER_LINE_HEIGHT: f32 = 4.;32pub const MIN_POPOVER_LINE_HEIGHT: f32 = 4.;
@@ -290,15 +289,18 @@ fn show_hover( · 256 unmodified lines
290 let delay = if ignore_timeout {289 let delay = if ignore_timeout {
291 None290 None
292 } else {291 } 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
293 // Construct delay task to wait for later299 // Construct delay task to wait for later
294 let total_delay = Some(300 let total_delay = Some(
295 cx.background_executor()301 cx.background_executor()
296 .timer(Duration::from_millis(hover_popover_delay)),302 .timer(Duration::from_millis(lsp_request_early)),
297 );303 );
298
299 cx.background_executor()
300 .timer(Duration::from_millis(HOVER_REQUEST_DELAY_MILLIS))
301 .await;
302 total_delay304 total_delay
303 };305 };
304 306
@@ -307,7 +309,6 @@ fn show_hover( · 2 unmodified lines
307 if let Some(delay) = delay {309 if let Some(delay) = delay {
308 delay.await;310 delay.await;
309 }311 }
310
311 let offset = anchor.to_offset(&snapshot.buffer_snapshot());312 let offset = anchor.to_offset(&snapshot.buffer_snapshot());
312 let local_diagnostic = if all_diagnostics_active {313 let local_diagnostic = if all_diagnostics_active {
313 None314 None