Skip to content

Commit

Permalink
workaround: The Ast on .zon files is unusable when an error occured o…
Browse files Browse the repository at this point in the history
…n the root expr
  • Loading branch information
Techatrix committed Dec 28, 2024
1 parent c88e029 commit 8406f8c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,9 @@ fn semanticTokensFullHandler(server: *Server, arena: std.mem.Allocator, request:

const handle = server.document_store.getHandle(request.textDocument.uri) orelse return null;

// Workaround: The Ast on .zon files is unusable when an error occured on the root expr
if (handle.tree.mode == .zon and handle.tree.errors.len > 0) return null;

var analyser = server.initAnalyser(handle);
defer analyser.deinit();
// semantic tokens can be quite expensive to compute on large files
Expand All @@ -1544,6 +1547,10 @@ fn semanticTokensRangeHandler(server: *Server, arena: std.mem.Allocator, request
if (server.config.semantic_tokens == .none) return null;

const handle = server.document_store.getHandle(request.textDocument.uri) orelse return null;

// Workaround: The Ast on .zon files is unusable when an error occured on the root expr
if (handle.tree.mode == .zon and handle.tree.errors.len > 0) return null;

const loc = offsets.rangeToLoc(handle.tree.source, request.range, server.offset_encoding);

var analyser = server.initAnalyser(handle);
Expand Down

0 comments on commit 8406f8c

Please sign in to comment.