From 805003cc77f32a5a57c65855d9ffe98d88886e39 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sat, 8 Jun 2024 20:05:29 +0200 Subject: [PATCH] fix: fallback to treating cli args with colons as plain filenames This allows us to open files that contain colons if they do not otherwise look like file:row:col. This also fixes opening absolute file paths on Windows. --- src/main.zig | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main.zig b/src/main.zig index c78157c..f76cf55 100644 --- a/src/main.zig +++ b/src/main.zig @@ -181,11 +181,16 @@ pub fn main() anyerror!void { var it = std.mem.splitScalar(u8, arg, ':'); curr.file = it.first(); if (it.next()) |line_| - curr.line = std.fmt.parseInt(usize, line_, 10) catch null; - if (it.next()) |col_| - curr.column = std.fmt.parseInt(usize, col_, 10) catch null; - if (it.next()) |col_| - curr.end_column = std.fmt.parseInt(usize, col_, 10) catch null; + curr.line = std.fmt.parseInt(usize, line_, 10) catch blk: { + curr.file = arg; + break :blk null; + }; + if (curr.line) |_| { + if (it.next()) |col_| + curr.column = std.fmt.parseInt(usize, col_, 10) catch null; + if (it.next()) |col_| + curr.end_column = std.fmt.parseInt(usize, col_, 10) catch null; + } } for (dests.items) |dest| {