aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2025-06-10 22:02:38 +0200
committerGitHub <noreply@github.com>2025-06-10 22:02:38 +0200
commit3f089f4d757e2a705056eb331c74442ab48862aa (patch)
tree8a8fc91171c637fb146a25176b85b8d0c8e58316
parentc39593e3c2a209630c20f5cc27cb29406276953c (diff)
parent8dd1daad7182cc7a9e218cb15e54fff09d47309d (diff)
Merge pull request #656 from BradLewis/fix/hover-string-slice
Add hover support for substring slices
-rw-r--r--src/server/analysis.odin5
-rw-r--r--tests/hover_test.odin14
2 files changed, 19 insertions, 0 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 952e991..f25250b 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1596,6 +1596,11 @@ resolve_slice_expression :: proc(ast_context: ^AstContext, slice_expr: ^ast.Slic
expr = v.expr
case SymbolDynamicArrayValue:
expr = v.expr
+ case SymbolUntypedValue:
+ if v.type == .String {
+ return symbol, true
+ }
+ return {}, false
case:
return {}, false
}
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index 2d7043a..cbb7ba9 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -839,6 +839,20 @@ ast_hover_proc_overload_definition :: proc(t: ^testing.T) {
test.expect_hover(t, &source, "test.foo: proc {\n\tfoo_none :: proc(allocator := context.allocator) -> (_: int, _: bool),\n\tfoo_int :: proc(i: int, allocator := context.allocator) -> (_: int, _: bool),\n}")
}
+
+@(test)
+ast_hover_sub_string_slices :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ main :: proc() {
+ str := "Hello, World!"
+ s{*}ub_str := str[0:5]
+ }
+ `
+ }
+
+ test.expect_hover(t, &source, "test.sub_str: string")
+}
/*
Waiting for odin fix