Do not allow cmd+click in invalid inlay context

Kirill Bulatov created

Change summary

crates/editor/src/element.rs               | 2 +-
crates/editor/src/link_go_to_definition.rs | 8 +++++---
2 files changed, 6 insertions(+), 4 deletions(-)

Detailed changes

crates/editor/src/element.rs 🔗

@@ -2755,7 +2755,7 @@ impl PointForPosition {
         }
     }
 
-    fn as_valid(&self) -> Option<DisplayPoint> {
+    pub fn as_valid(&self) -> Option<DisplayPoint> {
         if self.previous_valid == self.exact_unclipped && self.next_valid == self.exact_unclipped {
             Some(self.previous_valid)
         } else {
@@ -596,9 +596,11 @@ fn go_to_fetched_definition_of_kind(
             cx,
         );
 
-        match kind {
-            LinkDefinitionKind::Symbol => editor.go_to_definition(&Default::default(), cx),
-            LinkDefinitionKind::Type => editor.go_to_type_definition(&Default::default(), cx),
+        if point.as_valid().is_some() {
+            match kind {
+                LinkDefinitionKind::Symbol => editor.go_to_definition(&Default::default(), cx),
+                LinkDefinitionKind::Type => editor.go_to_type_definition(&Default::default(), cx),
+            }
         }
     }
 }