mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-20 02:47:34 +03:00
Fix selection bug in editor causing selections to be un-ended
This commit is contained in:
parent
078fd35f4f
commit
edb204511c
@ -1,28 +0,0 @@
|
|||||||
use futures::Future;
|
|
||||||
use gpui::Task;
|
|
||||||
use smallvec::{smallvec, SmallVec};
|
|
||||||
use text::Anchor;
|
|
||||||
|
|
||||||
use crate::Editor;
|
|
||||||
|
|
||||||
struct Completions {
|
|
||||||
trigger_characters: SmallVec<[char; 1]>,
|
|
||||||
language: Option<String>,
|
|
||||||
provider: Box<dyn Fn(&mut Editor, &Anchor, &str) -> Option<Task<String>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Completions {
|
|
||||||
fn new(f: impl Fn(&mut Editor, &Anchor, &str) -> Option<Task<String>> + 'static) -> Self {
|
|
||||||
Self {
|
|
||||||
trigger_characters: smallvec![],
|
|
||||||
language: None,
|
|
||||||
provider: Box::new(f),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Editor {
|
|
||||||
/// Provide completions to the editor when the given character is typed
|
|
||||||
///
|
|
||||||
fn provide_completions(config: Completions) {}
|
|
||||||
}
|
|
@ -456,6 +456,7 @@ impl EditorElement {
|
|||||||
event: &MouseUpEvent,
|
event: &MouseUpEvent,
|
||||||
position_map: &PositionMap,
|
position_map: &PositionMap,
|
||||||
text_bounds: Bounds<Pixels>,
|
text_bounds: Bounds<Pixels>,
|
||||||
|
interactive_bounds: &InteractiveBounds,
|
||||||
stacking_order: &StackingOrder,
|
stacking_order: &StackingOrder,
|
||||||
cx: &mut ViewContext<Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) {
|
) {
|
||||||
@ -466,7 +467,8 @@ impl EditorElement {
|
|||||||
editor.select(SelectPhase::End, cx);
|
editor.select(SelectPhase::End, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !pending_nonempty_selections
|
if interactive_bounds.visibly_contains(&event.position, cx)
|
||||||
|
&& !pending_nonempty_selections
|
||||||
&& event.modifiers.command
|
&& event.modifiers.command
|
||||||
&& text_bounds.contains(&event.position)
|
&& text_bounds.contains(&event.position)
|
||||||
&& cx.was_top_layer(&event.position, stacking_order)
|
&& cx.was_top_layer(&event.position, stacking_order)
|
||||||
@ -2542,22 +2544,18 @@ impl EditorElement {
|
|||||||
let interactive_bounds = interactive_bounds.clone();
|
let interactive_bounds = interactive_bounds.clone();
|
||||||
|
|
||||||
move |event: &MouseUpEvent, phase, cx| {
|
move |event: &MouseUpEvent, phase, cx| {
|
||||||
if phase == DispatchPhase::Bubble
|
if phase == DispatchPhase::Bubble {
|
||||||
{
|
|
||||||
// if interactive_bounds.visibly_contains(&event.position, cx) {
|
|
||||||
editor.update(cx, |editor, cx| {
|
editor.update(cx, |editor, cx| {
|
||||||
Self::mouse_up(
|
Self::mouse_up(
|
||||||
editor,
|
editor,
|
||||||
event,
|
event,
|
||||||
&position_map,
|
&position_map,
|
||||||
text_bounds,
|
text_bounds,
|
||||||
|
&interactive_bounds,
|
||||||
&stacking_order,
|
&stacking_order,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
// } else {
|
|
||||||
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
use crate::WindowAppearance;
|
|
||||||
use cocoa::{
|
|
||||||
appkit::{NSAppearanceNameVibrantDark, NSAppearanceNameVibrantLight},
|
|
||||||
base::id,
|
|
||||||
foundation::NSString,
|
|
||||||
};
|
|
||||||
use objc::{msg_send, sel, sel_impl};
|
|
||||||
use std::ffi::CStr;
|
|
||||||
|
|
||||||
impl WindowAppearance {
|
|
||||||
pub unsafe fn from_native(appearance: id) -> Self {
|
|
||||||
let name: id = msg_send![appearance, name];
|
|
||||||
if name == NSAppearanceNameVibrantLight {
|
|
||||||
Self::VibrantLight
|
|
||||||
} else if name == NSAppearanceNameVibrantDark {
|
|
||||||
Self::VibrantDark
|
|
||||||
} else if name == NSAppearanceNameAqua {
|
|
||||||
Self::Light
|
|
||||||
} else if name == NSAppearanceNameDarkAqua {
|
|
||||||
Self::Dark
|
|
||||||
} else {
|
|
||||||
println!(
|
|
||||||
"unknown appearance: {:?}",
|
|
||||||
CStr::from_ptr(name.UTF8String())
|
|
||||||
);
|
|
||||||
Self::Light
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[link(name = "AppKit", kind = "framework")]
|
|
||||||
extern "C" {
|
|
||||||
pub static NSAppearanceNameAqua: id;
|
|
||||||
pub static NSAppearanceNameDarkAqua: id;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user