Do not expand terminal selections on active drag

This commit is contained in:
Kirill Bulatov 2023-12-07 14:44:44 +02:00
parent f829120f51
commit b692b4c9c2
3 changed files with 18 additions and 16 deletions

View file

@ -1110,6 +1110,10 @@ impl AppContext {
} }
} }
} }
pub fn has_active_drag(&self) -> bool {
self.active_drag.is_some()
}
} }
impl Context for AppContext { impl Context for AppContext {

View file

@ -4,12 +4,12 @@ use crate::{
DevicePixels, DispatchNodeId, DispatchTree, DisplayId, Edges, Effect, Entity, EntityId, DevicePixels, DispatchNodeId, DispatchTree, DisplayId, Edges, Effect, Entity, EntityId,
EventEmitter, FileDropEvent, Flatten, FocusEvent, FontId, GlobalElementId, GlyphId, Hsla, EventEmitter, FileDropEvent, Flatten, FocusEvent, FontId, GlobalElementId, GlyphId, Hsla,
ImageData, InputEvent, IsZero, KeyBinding, KeyContext, KeyDownEvent, LayoutId, Model, ImageData, InputEvent, IsZero, KeyBinding, KeyContext, KeyDownEvent, LayoutId, Model,
ModelContext, Modifiers, MonochromeSprite, MouseButton, MouseDownEvent, MouseMoveEvent, ModelContext, Modifiers, MonochromeSprite, MouseButton, MouseMoveEvent, MouseUpEvent, Path,
MouseUpEvent, Path, Pixels, PlatformAtlas, PlatformDisplay, PlatformInputHandler, Pixels, PlatformAtlas, PlatformDisplay, PlatformInputHandler, PlatformWindow, Point,
PlatformWindow, Point, PolychromeSprite, PromptLevel, Quad, Render, RenderGlyphParams, PolychromeSprite, PromptLevel, Quad, Render, RenderGlyphParams, RenderImageParams,
RenderImageParams, RenderSvgParams, ScaledPixels, SceneBuilder, Shadow, SharedString, Size, RenderSvgParams, ScaledPixels, SceneBuilder, Shadow, SharedString, Size, Style, SubscriberSet,
Style, SubscriberSet, Subscription, Surface, TaffyLayoutEngine, Task, Underline, Subscription, Surface, TaffyLayoutEngine, Task, Underline, UnderlineStyle, View, VisualContext,
UnderlineStyle, View, VisualContext, WeakView, WindowBounds, WindowOptions, SUBPIXEL_VARIANTS, WeakView, WindowBounds, WindowOptions, SUBPIXEL_VARIANTS,
}; };
use anyhow::{anyhow, Context as _, Result}; use anyhow::{anyhow, Context as _, Result};
use collections::HashMap; use collections::HashMap;

View file

@ -1,9 +1,9 @@
use editor::{Cursor, HighlightedRange, HighlightedRangeLine}; use editor::{Cursor, HighlightedRange, HighlightedRangeLine};
use gpui::{ use gpui::{
black, div, point, px, red, relative, transparent_black, AnyElement, AsyncWindowContext, black, div, point, px, red, relative, transparent_black, AnyElement, AsyncWindowContext,
AvailableSpace, Bounds, DispatchPhase, Element, ElementId, FocusHandle, Font, FontStyle, AvailableSpace, Bounds, DispatchPhase, Element, ElementId, ExternalPaths, FocusHandle, Font,
FontWeight, HighlightStyle, Hsla, InteractiveElement, InteractiveElementState, IntoElement, FontStyle, FontWeight, HighlightStyle, Hsla, InteractiveElement, InteractiveElementState,
LayoutId, Model, ModelContext, ModifiersChangedEvent, MouseButton, Pixels, IntoElement, LayoutId, Model, ModelContext, ModifiersChangedEvent, MouseButton, Pixels,
PlatformInputHandler, Point, Rgba, ShapedLine, Size, StatefulInteractiveElement, Styled, PlatformInputHandler, Point, Rgba, ShapedLine, Size, StatefulInteractiveElement, Styled,
TextRun, TextStyle, TextSystem, UnderlineStyle, View, WhiteSpace, WindowContext, TextRun, TextStyle, TextSystem, UnderlineStyle, View, WhiteSpace, WindowContext,
}; };
@ -643,13 +643,11 @@ impl TerminalElement {
let connection = connection.clone(); let connection = connection.clone();
let focus = focus.clone(); let focus = focus.clone();
move |e, cx| { move |e, cx| {
if e.pressed_button.is_some() { if e.pressed_button.is_some() && focus.is_focused(cx) && !cx.has_active_drag() {
if focus.is_focused(cx) { connection.update(cx, |terminal, cx| {
connection.update(cx, |terminal, cx| { terminal.mouse_drag(e, origin, bounds);
terminal.mouse_drag(e, origin, bounds); cx.notify();
cx.notify(); })
})
}
} }
} }
}) })