From a540d2bf36f50f1f4fe9df2270fcadfbcba56e08 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Mon, 14 Jul 2025 17:38:20 +0200 Subject: [PATCH] fix: don't error loop if the configured file type parser is not found --- src/file_type_config.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/file_type_config.zig b/src/file_type_config.zig index c5afcd0..008bb9d 100644 --- a/src/file_type_config.zig +++ b/src/file_type_config.zig @@ -179,9 +179,9 @@ fn guess_first_line(content: []const u8) ?@This() { return null; } -pub fn create_syntax(file_type_config: @This(), allocator: std.mem.Allocator, query_cache: *syntax.QueryCache) !*syntax { +pub fn create_syntax(file_type_config: @This(), allocator: std.mem.Allocator, query_cache: *syntax.QueryCache) !?*syntax { return syntax.create( - syntax.FileType.get_by_name_static(file_type_config.parser orelse file_type_config.name) orelse return error.FileTypeNotFound, + syntax.FileType.get_by_name_static(file_type_config.parser orelse file_type_config.name) orelse return null, allocator, query_cache, ); @@ -192,7 +192,7 @@ pub fn create_syntax_guess_file_type( content: []const u8, file_path: ?[]const u8, query_cache: *syntax.QueryCache, -) !*syntax { +) !?*syntax { const file_type = guess(file_path, content) orelse return error.NotFound; return create_syntax(file_type, allocator, query_cache); }