Merge branch 'main' into ime-support-2

This commit is contained in:
Antonio Scandurra
2022-07-22 16:03:38 +02:00
209 changed files with 1859 additions and 9740 deletions
+6 -6
View File
@@ -30,8 +30,8 @@ use gpui::{
impl_actions, impl_internal_actions,
platform::CursorStyle,
text_layout, AppContext, AsyncAppContext, ClipboardItem, Element, ElementBox, Entity,
ModelHandle, MutableAppContext, RenderContext, Subscription, Task, View, ViewContext,
ViewHandle, WeakViewHandle,
ModelHandle, MouseButton, MutableAppContext, RenderContext, Subscription, Task, View,
ViewContext, ViewHandle, WeakViewHandle,
};
use highlight_matching_bracket::refresh_matching_bracket_highlights;
use hover_popover::{hide_hover, HoverState};
@@ -705,7 +705,7 @@ impl CompletionsMenu {
},
)
.with_cursor_style(CursorStyle::PointingHand)
.on_mouse_down(move |_, cx| {
.on_down(MouseButton::Left, move |_, cx| {
cx.dispatch_action(ConfirmCompletion {
item_ix: Some(item_ix),
});
@@ -838,7 +838,7 @@ impl CodeActionsMenu {
.boxed()
})
.with_cursor_style(CursorStyle::PointingHand)
.on_mouse_down(move |_, cx| {
.on_down(MouseButton::Left, move |_, cx| {
cx.dispatch_action(ConfirmCodeAction {
item_ix: Some(item_ix),
});
@@ -2664,13 +2664,13 @@ impl Editor {
enum Tag {}
Some(
MouseEventHandler::new::<Tag, _, _>(0, cx, |_, _| {
Svg::new("icons/zap.svg")
Svg::new("icons/bolt_8.svg")
.with_color(style.code_actions_indicator)
.boxed()
})
.with_cursor_style(CursorStyle::PointingHand)
.with_padding(Padding::uniform(3.))
.on_mouse_down(|_, cx| {
.on_down(MouseButton::Left, |_, cx| {
cx.dispatch_action(ToggleCodeActions {
deployed_from_indicator: true,
});
+13 -11
View File
@@ -25,7 +25,7 @@ use gpui::{
platform::CursorStyle,
text_layout::{self, Line, RunStyle, TextLayoutCache},
AppContext, Axis, Border, CursorRegion, Element, ElementBox, Event, EventContext,
LayoutContext, ModifiersChangedEvent, MouseButton, MouseEvent, MouseMovedEvent,
LayoutContext, ModifiersChangedEvent, MouseButton, MouseButtonEvent, MouseMovedEvent,
MutableAppContext, PaintContext, Quad, Scene, ScrollWheelEvent, SizeConstraint, ViewContext,
WeakViewHandle,
};
@@ -940,7 +940,7 @@ impl EditorElement {
cx.render(&editor, |_, cx| {
MouseEventHandler::new::<JumpIcon, _, _>(*key, cx, |state, _| {
let style = style.jump_icon.style_for(state, false);
Svg::new("icons/jump.svg")
Svg::new("icons/arrow_up_right_8.svg")
.with_color(style.color)
.constrained()
.with_width(style.icon_width)
@@ -953,7 +953,9 @@ impl EditorElement {
.boxed()
})
.with_cursor_style(CursorStyle::PointingHand)
.on_click(move |_, _, cx| cx.dispatch_action(jump_action.clone()))
.on_click(MouseButton::Left, move |_, cx| {
cx.dispatch_action(jump_action.clone())
})
.with_tooltip::<JumpIcon, _>(
*key,
"Jump to Buffer".to_string(),
@@ -1468,7 +1470,7 @@ impl Element for EditorElement {
}
match event {
Event::MouseDown(MouseEvent {
Event::MouseDown(MouseButtonEvent {
button: MouseButton::Left,
position,
cmd,
@@ -1486,12 +1488,12 @@ impl Element for EditorElement {
paint,
cx,
),
Event::MouseDown(MouseEvent {
Event::MouseDown(MouseButtonEvent {
button: MouseButton::Right,
position,
..
}) => self.mouse_right_down(*position, layout, paint, cx),
Event::MouseUp(MouseEvent {
Event::MouseUp(MouseButtonEvent {
button: MouseButton::Left,
position,
..
@@ -1662,12 +1664,12 @@ impl PaintState {
} else {
0
};
let column_overshoot = (0f32.max(x - line.width()) / layout.em_advance) as u32;
(
DisplayPoint::new(row, column),
DisplayPoint::new(row_overshoot, column_overshoot),
)
let point = snapshot.clip_point(DisplayPoint::new(row, column), Bias::Left);
let mut column_overshoot = (0f32.max(x - line.width()) / layout.em_advance) as u32;
column_overshoot = column_overshoot + column - point.column();
(point, DisplayPoint::new(row_overshoot, column_overshoot))
}
}
+10 -1
View File
@@ -7,7 +7,9 @@ use settings::Settings;
use util::TryFutureExt;
use workspace::Workspace;
use crate::{Anchor, DisplayPoint, Editor, EditorSnapshot, GoToDefinition, Select, SelectPhase};
use crate::{
Anchor, DisplayPoint, Editor, EditorSnapshot, Event, GoToDefinition, Select, SelectPhase,
};
#[derive(Clone, PartialEq)]
pub struct UpdateGoToDefinitionLink {
@@ -276,6 +278,13 @@ pub fn go_to_fetched_definition(
});
if !definitions.is_empty() {
editor_handle.update(cx, |editor, cx| {
if !editor.focused {
cx.focus_self();
cx.emit(Event::Activate);
}
});
Editor::navigate_to_definitions(workspace, editor_handle, definitions, cx);
} else {
editor_handle.update(cx, |editor, cx| {
+6 -1
View File
@@ -2,7 +2,7 @@ use context_menu::ContextMenuItem;
use gpui::{geometry::vector::Vector2F, impl_internal_actions, MutableAppContext, ViewContext};
use crate::{
DisplayPoint, Editor, EditorMode, FindAllReferences, GoToDefinition, Rename, SelectMode,
DisplayPoint, Editor, EditorMode, Event, FindAllReferences, GoToDefinition, Rename, SelectMode,
ToggleCodeActions,
};
@@ -23,6 +23,11 @@ pub fn deploy_context_menu(
&DeployMouseContextMenu { position, point }: &DeployMouseContextMenu,
cx: &mut ViewContext<Editor>,
) {
if !editor.focused {
cx.focus_self();
cx.emit(Event::Activate);
}
// Don't show context menu for inline editors
if editor.mode() != EditorMode::Full {
return;