aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-07 09:54:04 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-07 09:54:04 -0400
commit3bf249dc5d684995c9dcbd6045dd0b68595b4b0d (patch)
treeeb3d0cbbb9a6f9cd50017899d4db4ea9e2c9a5c9
parentb0074c3a0df4f6ccf145b8348b172a16fb13553a (diff)
Only show cast hover info if hovering over the `cast` keyword
-rw-r--r--src/server/hover.odin4
-rw-r--r--tests/hover_test.odin14
2 files changed, 16 insertions, 2 deletions
diff --git a/src/server/hover.odin b/src/server/hover.odin
index af83d0b..4941b87 100644
--- a/src/server/hover.odin
+++ b/src/server/hover.odin
@@ -78,7 +78,9 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
return {}, false, true
}
- if position_context.type_cast != nil {
+ if position_context.type_cast != nil && // check that we're actually on the 'cast' word
+ !position_in_node(position_context.type_cast.type, position_context.position) &&
+ !position_in_node(position_context.type_cast.expr, position_context.position) {
if str, ok := keywords_docs[position_context.type_cast.tok.text]; ok {
hover.contents.kind = "markdown"
hover.contents.value = str
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index daff8e4..dea4b3b 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -4431,7 +4431,6 @@ ast_hover_overloaded_proc_slice_dynamic_array :: proc(t: ^testing.T) {
test.expect_hover(t, &source, "test.foo: proc(array: $A/[dynamic]$T)")
}
-
@(test)
ast_hover_proc_call_implicit_selector_with_default_value :: proc(t: ^testing.T) {
source := test.Source {
@@ -4458,6 +4457,19 @@ ast_hover_proc_call_implicit_selector_with_default_value :: proc(t: ^testing.T)
}
test.expect_hover(t, &source, "test.Option: .B")
}
+
+@(test)
+ast_hover_casted_variable :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ main :: proc() {
+ foo: int = 25
+ bar := cast(f32)fo{*}o
+ }
+ `,
+ }
+ test.expect_hover(t, &source, "test.foo: int")
+}
/*
Waiting for odin fix