Skip to content

Commit

Permalink
fix semanticTokens/range when enclosing the root node
Browse files Browse the repository at this point in the history
Ideally, when reaching the end of the document, ZLS should not try to send over all semantic tokens of the document on a range request.
  • Loading branch information
Techatrix committed Jul 26, 2024
1 parent 3fe30cf commit 45eb38e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/features/semantic_tokens.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,10 @@ pub fn writeSemanticTokens(
.limited = limited,
};

const nodes = if (loc) |l| try ast.nodesAtLoc(arena, handle.tree, l) else handle.tree.rootDecls();
var nodes = if (loc) |l| try ast.nodesAtLoc(arena, handle.tree, l) else handle.tree.rootDecls();
if (nodes.len == 1 and nodes[0] == 0) {
nodes = handle.tree.rootDecls();
}

// reverse the ast from the root declarations
for (nodes) |child| {
Expand Down

0 comments on commit 45eb38e

Please sign in to comment.