Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/ast.zig
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,10 @@ pub fn paramFirstToken(tree: *const Ast, param: Ast.full.FnProto.Param, include_
return (if (include_doc_comment) param.first_doc_comment else null) orelse
param.comptime_noalias orelse
param.name_token orelse
tree.firstToken(param.type_expr.?);
if (param.type_expr) |te|
tree.firstToken(te)
else
param.anytype_ellipsis3.?;
}

pub fn paramLastToken(tree: *const Ast, param: Ast.full.FnProto.Param) Ast.TokenIndex {
Expand Down
9 changes: 9 additions & 0 deletions tests/lsp_features/selection_range.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ test "between nodes" {
, &.{});
}

test "variadic function" {
try testSelectionRange(
\\fn foo(...<>) void {}
, &.{
"...",
"fn foo(...) void",
});
}

test "expression inside function" {
try testSelectionRange(
\\fn main() void {
Expand Down
Loading