diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-06-11 16:29:52 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-06-11 16:32:52 -0400 |
| commit | 700d8848c751b48879ae75ff5ccb3fe7c3fa1481 (patch) | |
| tree | 0352ff4e75850b1492785f1ec1949cbf23798fe4 /tests | |
| parent | f09e5fc3379ae4e706193ee777028c47293c9335 (diff) | |
Fix issue with the LSP incorrectly inferring positions if the file started with an empty line
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/definition_test.odin | 27 | ||||
| -rw-r--r-- | tests/hover_test.odin | 18 | ||||
| -rw-r--r-- | tests/references_test.odin | 23 |
3 files changed, 68 insertions, 0 deletions
diff --git a/tests/definition_test.odin b/tests/definition_test.odin index 8718f3a..1c51b8e 100644 --- a/tests/definition_test.odin +++ b/tests/definition_test.odin @@ -446,3 +446,30 @@ ast_goto_variable_field_definition_with_selector_expr :: proc(t: ^testing.T) { test.expect_definition_locations(t, &source, {location}) } + + +@(test) +ast_goto_struct_definition_with_empty_line_at_top_of_file :: proc(t: ^testing.T) { + source := test.Source { + main = ` + package test + + Foo :: struct { + bar: int, + } + + main :: proc() { + foo := F{*}oo{} + } + ` + } + + location := common.Location { + range = { + start = {line = 3, character = 2}, + end = {line = 3, character = 5}, + }, + } + + test.expect_definition_locations(t, &source, {location}) +} diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 9cc1d5b..fc3b730 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -895,6 +895,24 @@ ast_hover_struct_field_use :: proc(t: ^testing.T) { test.expect_hover(t, &source, "Bar.foo: test.Foo :: struct {\n\tvalue: int,\n}") } + +@(test) +ast_hover_empty_line_at_top_of_file :: proc(t: ^testing.T) { + source := test.Source { + main = ` + package test + Foo :: struct { + bar: int, + } + + main :: proc() { + foo := F{*}oo{} + } + ` + } + + test.expect_hover(t, &source, "test.Foo: struct {\n\tbar: int,\n}") +} /* Waiting for odin fix diff --git a/tests/references_test.odin b/tests/references_test.odin index 3bc0862..84de7a5 100644 --- a/tests/references_test.odin +++ b/tests/references_test.odin @@ -30,6 +30,29 @@ reference_variables_in_function :: proc(t: ^testing.T) { } @(test) +reference_variables_in_function_with_empty_line_at_top_of_file :: proc(t: ^testing.T) { + source := test.Source { + main = ` + package test + my_function :: proc() { + a := 2 + b := a + c := 2 + b{*} + } + `, + } + + test.expect_reference_locations( + t, + &source, + { + {range = {start = {line = 4, character = 3}, end = {line = 4, character = 4}}}, + {range = {start = {line = 5, character = 12}, end = {line = 5, character = 13}}}, + }, + ) +} + +@(test) reference_variables_in_function_parameters :: proc(t: ^testing.T) { source := test.Source { main = `package test |