From a5292b4e56ed085281320f499864a42e6ea5f120 Mon Sep 17 00:00:00 2001 From: Adriel Velazquez Date: Wed, 5 Feb 2025 23:52:56 -0800 Subject: [PATCH] Cleaning up to be able to do this in windows --- src/Surface.zig | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index 5cbe15fab..e9d2b180b 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -18,6 +18,7 @@ pub const Message = apprt.surface.Message; const std = @import("std"); const builtin = @import("builtin"); const assert = std.debug.assert; +const getenv = @import("os/env.zig").getenv; const Allocator = std.mem.Allocator; const ArenaAllocator = std.heap.ArenaAllocator; const global_state = &@import("global.zig").state; @@ -4321,16 +4322,16 @@ fn openScreenFile( self: *Surface, file_path: []const u8, ) !void { - const editor = std.posix.getenv("EDITOR") orelse { - std.log.debug("EDITOR environment variable not set", .{}); - return error.EnvironmentVariableNotFound; + const editor = getenv(self.alloc, "EDITOR") catch |err| { + return err; }; - - const command = try std.fmt.allocPrint(self.alloc, "{s} {s}\n", .{ editor, file_path }); - self.io.queueMessage(try termio.Message.writeReq( - self.alloc, - command, - ), .unlocked); + if (editor) |res| { + const command = try std.fmt.allocPrint(self.alloc, "{s} {s}\n", .{ res.value, file_path }); + self.io.queueMessage(try termio.Message.writeReq( + self.alloc, + command, + ), .unlocked); + } } /// The portion of the screen to write for writeScreenFile.