From 57dfa2ee9fcff515820de357ab1664e313aacb67 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sat, 12 Oct 2024 20:26:40 +0200 Subject: [PATCH] feat: add command to toggle syntax highlighting (S-F10) --- src/syntax.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/syntax.zig b/src/syntax.zig index e85d859..41a3e18 100644 --- a/src/syntax.zig +++ b/src/syntax.zig @@ -58,8 +58,15 @@ pub fn destroy(self: *Self) void { self.allocator.destroy(self); } +pub fn reset(self: *Self) void { + if (self.tree) |tree| { + tree.destroy(); + self.tree = null; + } +} + pub fn refresh_full(self: *Self, content: []const u8) !void { - if (self.tree) |tree| tree.destroy(); + self.reset(); self.tree = try self.parser.parseString(null, content); }