Skip to content

Commit 31963d0

Browse files
committed
fix paramFirstToken on variadic function
1 parent d5d31d9 commit 31963d0

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/ast.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,10 @@ pub fn paramFirstToken(tree: *const Ast, param: Ast.full.FnProto.Param, include_
859859
return (if (include_doc_comment) param.first_doc_comment else null) orelse
860860
param.comptime_noalias orelse
861861
param.name_token orelse
862-
tree.firstToken(param.type_expr.?);
862+
if (param.type_expr) |te|
863+
tree.firstToken(te)
864+
else
865+
param.anytype_ellipsis3.?;
863866
}
864867

865868
pub fn paramLastToken(tree: *const Ast, param: Ast.full.FnProto.Param) Ast.TokenIndex {

tests/lsp_features/selection_range.zig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ test "between nodes" {
2323
, &.{});
2424
}
2525

26+
test "variadic function" {
27+
try testSelectionRange(
28+
\\fn foo(...<>) void {}
29+
, &.{
30+
"...",
31+
"fn foo(...) void",
32+
});
33+
}
34+
2635
test "expression inside function" {
2736
try testSelectionRange(
2837
\\fn main() void {

0 commit comments

Comments
 (0)