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
Unified · Split
| @@ -27,7 +27,6 @@ use ui::{Scrollbars, WithScrollbar, prelude::*, theme_is_transparent}; · 26 unmodified lines | ||
| 27 | 27 | use url::Url; |
| 28 | 28 | use util::TryFutureExt; |
| 29 | 29 | use workspace::{OpenOptions, OpenVisible, Workspace}; |
| 30 | −pub const HOVER_REQUEST_DELAY_MILLIS: u64 = 200; | |
| 31 | 30 | |
| 32 | 31 | pub const MIN_POPOVER_CHARACTER_WIDTH: f32 = 20.; |
| 33 | 32 | pub const MIN_POPOVER_LINE_HEIGHT: f32 = 4.; |
| @@ -290,15 +289,18 @@ fn show_hover( · 256 unmodified lines | ||
| 290 | 289 | let delay = if ignore_timeout { |
| 291 | 290 | None |
| 292 | 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 | 299 | // Construct delay task to wait for later |
| 294 | 300 | let total_delay = Some( |
| 295 | 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 | 304 | total_delay |
| 303 | 305 | }; |
| 304 | 306 | |
| @@ -307,7 +309,6 @@ fn show_hover( · 2 unmodified lines | ||
| 307 | 309 | if let Some(delay) = delay { |
| 308 | 310 | delay.await; |
| 309 | 311 | } |
| 310 | − | |
| 311 | 312 | let offset = anchor.to_offset(&snapshot.buffer_snapshot()); |
| 312 | 313 | let local_diagnostic = if all_diagnostics_active { |
| 313 | 314 | None |