editor: Change drag_and_drop_selection
cursor on delay elapsed + Add drag_and_drop_selection
delay setting (#33928)
When [`drag_and_drop_selection` is true](https://zed.dev/docs/configuring-zed#drag-and-drop-selection), users can make a selection in the buffer and then drag and drop it to a new location. However, the editor forces users to wait 300ms after mouse down before dragging. If users try to drag before this delay has elapsed, they will create a new text selection instead, which can create the impression that drag and drop does not work. I made two changes to improve the UX of this feature: * If users do not want a delay before drag and drop is enabled, they can set the `drag_and_drop_selection.delay_ms` setting to 0. * If the user has done a mouse down on a text selection, the cursor changes to a copy affordance as soon as the configured delay has elapsed, rather than waiting for them to start dragging. This way they don't need to guess at when the delay has elapsed. The default settings for this feature are now: ``` "drag_and_drop_selection": { "enabled": true, "delay_ms": 300 } ``` Closes #33915 Before: https://github.com/user-attachments/assets/7b2f986f-9c67-4b2b-a10e-757c3e9c934b After: https://github.com/user-attachments/assets/726d0dbf-e58b-41ad-93d2-1a758640b422 Release Notes: - Migrate `drag_and_drop_selection` setting to `drag_and_drop_selection.enabled`. - Add `drag_and_drop_selection.delay_ms` setting to configure the delay that must elapse before drag and drop is allowed. - Show a ready to drag cursor affordance as soon as the delay has elapsed --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
This commit is contained in:
parent
4ed206b37c
commit
1569b662ff
8 changed files with 110 additions and 17 deletions
|
@ -93,3 +93,9 @@ pub(crate) mod m_2025_06_27 {
|
|||
|
||||
pub(crate) use settings::SETTINGS_PATTERNS;
|
||||
}
|
||||
|
||||
pub(crate) mod m_2025_07_08 {
|
||||
mod settings;
|
||||
|
||||
pub(crate) use settings::SETTINGS_PATTERNS;
|
||||
}
|
||||
|
|
37
crates/migrator/src/migrations/m_2025_07_08/settings.rs
Normal file
37
crates/migrator/src/migrations/m_2025_07_08/settings.rs
Normal file
|
@ -0,0 +1,37 @@
|
|||
use std::ops::Range;
|
||||
use tree_sitter::{Query, QueryMatch};
|
||||
|
||||
use crate::MigrationPatterns;
|
||||
use crate::patterns::SETTINGS_ROOT_KEY_VALUE_PATTERN;
|
||||
|
||||
pub const SETTINGS_PATTERNS: MigrationPatterns = &[(
|
||||
SETTINGS_ROOT_KEY_VALUE_PATTERN,
|
||||
migrate_drag_and_drop_selection,
|
||||
)];
|
||||
|
||||
fn migrate_drag_and_drop_selection(
|
||||
contents: &str,
|
||||
mat: &QueryMatch,
|
||||
query: &Query,
|
||||
) -> Option<(Range<usize>, String)> {
|
||||
let name_ix = query.capture_index_for_name("name")?;
|
||||
let name_range = mat.nodes_for_capture_index(name_ix).next()?.byte_range();
|
||||
let name = contents.get(name_range)?;
|
||||
|
||||
if name != "drag_and_drop_selection" {
|
||||
return None;
|
||||
}
|
||||
|
||||
let value_ix = query.capture_index_for_name("value")?;
|
||||
let value_node = mat.nodes_for_capture_index(value_ix).next()?;
|
||||
let value_range = value_node.byte_range();
|
||||
let value = contents.get(value_range.clone())?;
|
||||
|
||||
match value {
|
||||
"true" | "false" => {
|
||||
let replacement = format!("{{\n \"enabled\": {}\n }}", value);
|
||||
Some((value_range, replacement))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
|
@ -160,6 +160,10 @@ pub fn migrate_settings(text: &str) -> Result<Option<String>> {
|
|||
migrations::m_2025_06_27::SETTINGS_PATTERNS,
|
||||
&SETTINGS_QUERY_2025_06_27,
|
||||
),
|
||||
(
|
||||
migrations::m_2025_07_08::SETTINGS_PATTERNS,
|
||||
&SETTINGS_QUERY_2025_07_08,
|
||||
),
|
||||
];
|
||||
run_migrations(text, migrations)
|
||||
}
|
||||
|
@ -270,6 +274,10 @@ define_query!(
|
|||
SETTINGS_QUERY_2025_06_27,
|
||||
migrations::m_2025_06_27::SETTINGS_PATTERNS
|
||||
);
|
||||
define_query!(
|
||||
SETTINGS_QUERY_2025_07_08,
|
||||
migrations::m_2025_07_08::SETTINGS_PATTERNS
|
||||
);
|
||||
|
||||
// custom query
|
||||
static EDIT_PREDICTION_SETTINGS_MIGRATION_QUERY: LazyLock<Query> = LazyLock::new(|| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue