Skip to content

Commit

Permalink
fix index out of bound in enum completions
Browse files Browse the repository at this point in the history
Thank you zigtools/sus
  • Loading branch information
Techatrix committed Sep 16, 2024
1 parent 83aeff4 commit f05b8b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/features/completions.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,7 @@ fn getEnumLiteralContext(
(dot_token_index - 2)
else
(dot_token_index - 1);
if (token_index == 0) return null;

var dot_context = EnumLiteralContext{ .likely = .enum_literal };

Expand Down
6 changes: 6 additions & 0 deletions tests/lsp_features/completion.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2610,6 +2610,12 @@ test "enum completion on out of bound parameter index" {
, &.{});
}

test "enum completion on out of bound token index" {
try testCompletion(
\\ = 1.<cursor>
, &.{});
}

test "combine doc comments of declaration and definition" {
if (true) return error.SkipZigTest; // TODO
try testCompletion(
Expand Down

0 comments on commit f05b8b3

Please sign in to comment.