From 354c02061276966e5d8dafe27b52624faaac5891 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 26 Jul 2023 14:57:46 -0700 Subject: [PATCH] Block extra drag events in original drag handlers --- crates/editor/src/element.rs | 8 ++++++++ crates/gpui/src/elements/resizable.rs | 3 +++ crates/terminal/src/terminal.rs | 2 +- crates/terminal_view/src/terminal_element.rs | 4 ++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index b48fa5b56dd831f82852f224370500027302f3af..b9bf74ee85f8bbc3c338a75b4cd1bf39bc0a53cb 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -172,6 +172,10 @@ impl EditorElement { .on_drag(MouseButton::Left, { let position_map = position_map.clone(); move |event, editor, cx| { + if event.end { + return; + } + if !Self::mouse_dragged( editor, event.platform_event, @@ -1235,6 +1239,10 @@ impl EditorElement { }) .on_drag(MouseButton::Left, { move |event, editor: &mut Editor, cx| { + if event.end { + return; + } + let y = event.prev_mouse_position.y(); let new_y = event.position.y(); if thumb_top < y && y < thumb_bottom { diff --git a/crates/gpui/src/elements/resizable.rs b/crates/gpui/src/elements/resizable.rs index da4b3473b3069ea343d7acdd0cc85c262e7a76cf..73bec5521cbca1987e945cd2974071eae2c9eac6 100644 --- a/crates/gpui/src/elements/resizable.rs +++ b/crates/gpui/src/elements/resizable.rs @@ -147,6 +147,9 @@ impl Element for Resizable { let max_size = side.relevant_component(constraint.max); let on_resize = self.on_resize.clone(); move |event, view: &mut V, cx| { + if event.end { + return; + } let new_size = min_size .max(prev_size + side.compute_delta(event)) .min(max_size) diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index e3109102d10bdb23de8594c51322df9958b3d83b..06befd5f4ef5b76a4cedccad0fdd526c7d6c0edc 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -78,7 +78,7 @@ lazy_static! { // * use more strict regex for `file://` protocol matching: original regex has `file:` inside, but we want to avoid matching `some::file::module` strings. static ref URL_REGEX: RegexSearch = RegexSearch::new(r#"(ipfs:|ipns:|magnet:|mailto:|gemini://|gopher://|https://|http://|news:|file://|git://|ssh:|ftp://)[^\u{0000}-\u{001F}\u{007F}-\u{009F}<>"\s{-}\^⟨⟩`]+"#).unwrap(); - static ref WORD_REGEX: RegexSearch = RegexSearch::new("[\\w.:/@-~]+").unwrap(); + static ref WORD_REGEX: RegexSearch = RegexSearch::new(r#"[\w.:/@\-~]+"#).unwrap(); } ///Upward flowing events, for changing the title and such diff --git a/crates/terminal_view/src/terminal_element.rs b/crates/terminal_view/src/terminal_element.rs index e29beb3ad52592bee273a34c24aa25b60c172754..194b0a9259d4292aea67c94197a344e49eedf8d1 100644 --- a/crates/terminal_view/src/terminal_element.rs +++ b/crates/terminal_view/src/terminal_element.rs @@ -411,6 +411,10 @@ impl TerminalElement { }) // Update drag selections .on_drag(MouseButton::Left, move |event, _: &mut TerminalView, cx| { + if event.end { + return; + } + if cx.is_self_focused() { if let Some(conn_handle) = connection.upgrade(cx) { conn_handle.update(cx, |terminal, cx| {