From 87b7954669b7e9d625ec383740e827606c36aa4a Mon Sep 17 00:00:00 2001 From: Alexandros Naskos Date: Tue, 12 Jan 2021 14:05:08 +0200 Subject: [PATCH] Fixed semantic token hihglighting issue when a regular comment was following a doc comment --- src/semantic_tokens.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/semantic_tokens.zig b/src/semantic_tokens.zig index 28dfea1..a278abc 100644 --- a/src/semantic_tokens.zig +++ b/src/semantic_tokens.zig @@ -68,6 +68,10 @@ const Builder = struct { self.handle.tree.token_locs[current_token].start else 0; + + if (start_idx > self.handle.tree.token_locs[token].start) + return; + const delta_loc = offsets.tokenRelativeLocation(self.handle.tree, start_idx, token, self.encoding) catch return; try self.arr.appendSlice(&[_]u32{ @truncate(u32, delta_loc.line), @@ -129,8 +133,8 @@ const GapHighlighter = struct { const tok_id = self.builder.handle.tree.token_ids[tok]; if (tok_id == .LineComment) { try writeToken(self.builder, tok, .comment); - } else if (tok_id == .ContainerDocComment) { - try writeTokenMod(self.builder, tok, .comment, TokenModifiers{ .documentation = true }); + } else if (tok_id == .ContainerDocComment or tok_id == .DocComment) { + try writeTokenMod(self.builder, tok, .comment, .{ .documentation = true }); } else if (@enumToInt(tok_id) >= @enumToInt(std.zig.Token.Id.Keyword_align) and @enumToInt(tok_id) <= @enumToInt(std.zig.Token.Id.Keyword_while)) {