From 0119e51a27d6a1bb244eda3eaa397297ae96c64d Mon Sep 17 00:00:00 2001 From: Roman Pytkov Date: Fri, 27 Feb 2026 01:59:30 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D1=83=D0=BF=D1=80=D0=BE=D1=89=D0=B5=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ui/menu_bar.zig | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/ui/menu_bar.zig b/src/ui/menu_bar.zig index c59764e..0bc1ff1 100644 --- a/src/ui/menu_bar.zig +++ b/src/ui/menu_bar.zig @@ -58,32 +58,8 @@ fn saveAsDialog(ctx: *WindowContext) void { defer ctx.allocator.free(path_z); const path_raw = path_z[0..path_z.len]; - const resolved = ensureJsonPath(ctx.allocator, path_raw) catch |err| { - std.debug.print("Save path error: {}\n", .{err}); - return; - }; - defer if (resolved.owned) ctx.allocator.free(resolved.path); - - document_json.saveToFile(&open_doc.document, resolved.path) catch |err| { + document_json.saveToFile(&open_doc.document, path_raw) catch |err| { std.debug.print("Save file error: {}\n", .{err}); return; }; } - -const ResolvedPath = struct { - path: []const u8, - owned: bool, -}; - -fn ensureJsonPath(allocator: std.mem.Allocator, path: []const u8) !ResolvedPath { - if (endsWithIgnoreCase(path, ".json")) { - return .{ .path = path, .owned = false }; - } - const joined = try std.mem.concat(allocator, u8, &.{ path, ".json" }); - return .{ .path = joined, .owned = true }; -} - -fn endsWithIgnoreCase(haystack: []const u8, needle: []const u8) bool { - if (haystack.len < needle.len) return false; - return std.ascii.eqlIgnoreCase(haystack[haystack.len - needle.len ..], needle); -}