From b0096bed74cb93cacb923e79d3b9a13f16ec059e Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 15 Jul 2025 18:07:15 +0200 Subject: [PATCH 1/2] feat: create parent directories if needed when saving new files closes #84 --- src/buffer/Buffer.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/buffer/Buffer.zig b/src/buffer/Buffer.zig index c90bf76..0c8e5c4 100644 --- a/src/buffer/Buffer.zig +++ b/src/buffer/Buffer.zig @@ -1338,6 +1338,8 @@ pub fn store_to_existing_file_const(self: *const Self, file_path: []const u8) St } pub fn store_to_new_file_const(self: *const Self, file_path: []const u8) StoreToFileError!void { + if (std.fs.path.dirname(file_path)) |dir_name| + try cwd().makePath(dir_name); const file = try cwd().createFile(file_path, .{ .read = true, .truncate = true }); defer file.close(); try self.store_to_file_const(file); From 0a74bab466ebac025886c5bc370b64afcd971bac Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 15 Jul 2025 18:35:19 +0200 Subject: [PATCH 2/2] fix: bitrot in syntax.FileType.guess_static --- src/syntax/src/file_type.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/syntax/src/file_type.zig b/src/syntax/src/file_type.zig index c59a922..88a1494 100644 --- a/src/syntax/src/file_type.zig +++ b/src/syntax/src/file_type.zig @@ -30,7 +30,7 @@ pub fn get_all() []const FileType { pub fn guess_static(file_path: ?[]const u8, content: []const u8) ?FileType { if (guess_first_line_static(content)) |ft| return ft; - for (static_file_types.values()) |*file_type| + for (static_file_types.values()) |file_type| if (file_path) |fp| if (match_file_type(file_type.extensions, fp)) return file_type; return null; @@ -38,7 +38,7 @@ pub fn guess_static(file_path: ?[]const u8, content: []const u8) ?FileType { fn guess_first_line_static(content: []const u8) ?FileType { const first_line = if (std.mem.indexOf(u8, content, "\n")) |pos| content[0..pos] else content; - for (static_file_types) |*file_type| + for (static_file_types.values()) |file_type| if (file_type.first_line_matches) |match| if (match_first_line(match.prefix, match.content, first_line)) return file_type;