Add DelayMs type for settings (#40659)

Closes #40610

Release Notes:

- N/A
This commit is contained in:
Julia Ryan
2025-10-20 04:34:55 +00:00
committed by GitHub
parent 59b87d5c71
commit 1d3bf9789e
16 changed files with 132 additions and 127 deletions
+2 -2
View File
@@ -6772,7 +6772,7 @@ impl Editor {
if let Some(state) = &mut self.inline_blame_popover {
state.hide_task.take();
} else {
let blame_popover_delay = EditorSettings::get_global(cx).hover_popover_delay;
let blame_popover_delay = EditorSettings::get_global(cx).hover_popover_delay.0;
let blame_entry = blame_entry.clone();
let show_task = cx.spawn(async move |editor, cx| {
if !ignore_timeout {
@@ -6863,7 +6863,7 @@ impl Editor {
return None;
}
let debounce = EditorSettings::get_global(cx).lsp_highlight_debounce;
let debounce = EditorSettings::get_global(cx).lsp_highlight_debounce.0;
self.document_highlights_task = Some(cx.spawn(async move |this, cx| {
cx.background_executor()
.timer(Duration::from_millis(debounce))
+4 -4
View File
@@ -5,7 +5,7 @@ use language::CursorShape;
use project::project_settings::DiagnosticSeverity;
use settings::Settings;
pub use settings::{
CurrentLineHighlight, DisplayIn, DocumentColorsRenderMode, DoubleClickInMultibuffer,
CurrentLineHighlight, DelayMs, DisplayIn, DocumentColorsRenderMode, DoubleClickInMultibuffer,
GoToDefinitionFallback, HideMouseMode, MinimapThumb, MinimapThumbBorder, MultiCursorModifier,
ScrollBeyondLastLine, ScrollbarDiagnostics, SeedQuerySetting, ShowMinimap, SnippetSortOrder,
};
@@ -20,9 +20,9 @@ pub struct EditorSettings {
pub current_line_highlight: CurrentLineHighlight,
pub selection_highlight: bool,
pub rounded_selection: bool,
pub lsp_highlight_debounce: u64,
pub lsp_highlight_debounce: DelayMs,
pub hover_popover_enabled: bool,
pub hover_popover_delay: u64,
pub hover_popover_delay: DelayMs,
pub toolbar: Toolbar,
pub scrollbar: Scrollbar,
pub minimap: Minimap,
@@ -147,7 +147,7 @@ pub struct DragAndDropSelection {
/// The delay in milliseconds that must elapse before drag and drop is allowed. Otherwise, a new text selection is created.
///
/// Default: 300
pub delay: u64,
pub delay: DelayMs,
}
/// Default options for buffer and project search items.
+8 -2
View File
@@ -1070,7 +1070,10 @@ impl EditorElement {
ref mouse_down_time,
} => {
let drag_and_drop_delay = Duration::from_millis(
EditorSettings::get_global(cx).drag_and_drop_selection.delay,
EditorSettings::get_global(cx)
.drag_and_drop_selection
.delay
.0,
);
if mouse_down_time.elapsed() >= drag_and_drop_delay {
let drop_cursor = Selection {
@@ -6172,7 +6175,10 @@ impl EditorElement {
} = &editor.selection_drag_state
{
let drag_and_drop_delay = Duration::from_millis(
EditorSettings::get_global(cx).drag_and_drop_selection.delay,
EditorSettings::get_global(cx)
.drag_and_drop_selection
.delay
.0,
);
if mouse_down_time.elapsed() >= drag_and_drop_delay {
window.set_cursor_style(
+3 -3
View File
@@ -154,7 +154,7 @@ pub fn hover_at_inlay(
hide_hover(editor, cx);
}
let hover_popover_delay = EditorSettings::get_global(cx).hover_popover_delay;
let hover_popover_delay = EditorSettings::get_global(cx).hover_popover_delay.0;
let task = cx.spawn_in(window, async move |this, cx| {
async move {
@@ -275,7 +275,7 @@ fn show_hover(
return None;
}
let hover_popover_delay = EditorSettings::get_global(cx).hover_popover_delay;
let hover_popover_delay = EditorSettings::get_global(cx).hover_popover_delay.0;
let all_diagnostics_active = editor.active_diagnostics == ActiveDiagnostic::All;
let active_group_id = if let ActiveDiagnostic::Group(group) = &editor.active_diagnostics {
Some(group.group_id)
@@ -1004,7 +1004,7 @@ mod tests {
use text::Bias;
fn get_hover_popover_delay(cx: &gpui::TestAppContext) -> u64 {
cx.read(|cx: &App| -> u64 { EditorSettings::get_global(cx).hover_popover_delay })
cx.read(|cx: &App| -> u64 { EditorSettings::get_global(cx).hover_popover_delay.0 })
}
impl InfoPopover {