@@ -113,6 +113,11 @@ pub struct ConfirmCodeAction {
pub item_ix: Option<usize>,
}
+#[derive(Clone, Default)]
+pub struct GoToDefinitionAt {
+ pub location: Option<DisplayPoint>,
+}
+
actions!(
editor,
[
@@ -173,10 +178,10 @@ actions!(
ToggleComments,
SelectLargerSyntaxNode,
SelectSmallerSyntaxNode,
+ GoToDefinition,
MoveToEnclosingBracket,
UndoSelection,
RedoSelection,
- GoToDefinition,
FindAllReferences,
Rename,
ConfirmRename,
@@ -204,7 +209,7 @@ impl_actions!(
]
);
-impl_internal_actions!(editor, [Scroll, Select]);
+impl_internal_actions!(editor, [Scroll, Select, GoToDefinitionAt]);
enum DocumentHighlightRead {}
enum DocumentHighlightWrite {}
@@ -5,7 +5,7 @@ use super::{
};
use crate::{
display_map::{DisplaySnapshot, TransformBlock},
- EditorStyle,
+ EditorStyle, GoToDefinition,
};
use clock::ReplicaId;
use collections::{BTreeMap, HashMap};
@@ -102,6 +102,7 @@ impl EditorElement {
fn mouse_down(
&self,
position: Vector2F,
+ cmd: bool,
alt: bool,
shift: bool,
mut click_count: usize,
@@ -118,7 +119,11 @@ impl EditorElement {
let snapshot = self.snapshot(cx.app);
let (position, overshoot) = paint.point_for_position(&snapshot, layout, position);
- if shift && alt {
+ if cmd {
+ cx.dispatch_action(GoToDefinitionAt {
+ location: Some(position),
+ });
+ } else if shift && alt {
cx.dispatch_action(Select(SelectPhase::BeginColumnar {
position,
overshoot,
@@ -1222,11 +1227,21 @@ impl Element for EditorElement {
match event {
Event::LeftMouseDown {
position,
+ cmd,
alt,
shift,
click_count,
..
- } => self.mouse_down(*position, *alt, *shift, *click_count, layout, paint, cx),
+ } => self.mouse_down(
+ *position,
+ *cmd,
+ *alt,
+ *shift,
+ *click_count,
+ layout,
+ paint,
+ cx,
+ ),
Event::LeftMouseUp { position, .. } => self.mouse_up(*position, cx),
Event::LeftMouseDragged { position } => {
self.mouse_dragged(*position, layout, paint, cx)