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.
This commit is contained in:
CJ van den Berg 2024-06-08 20:05:29 +02:00
parent 4d8d538c9a
commit 805003cc77

View file

@ -181,11 +181,16 @@ pub fn main() anyerror!void {
var it = std.mem.splitScalar(u8, arg, ':'); var it = std.mem.splitScalar(u8, arg, ':');
curr.file = it.first(); curr.file = it.first();
if (it.next()) |line_| if (it.next()) |line_|
curr.line = std.fmt.parseInt(usize, line_, 10) catch null; curr.line = std.fmt.parseInt(usize, line_, 10) catch blk: {
if (it.next()) |col_| curr.file = arg;
curr.column = std.fmt.parseInt(usize, col_, 10) catch null; break :blk null;
if (it.next()) |col_| };
curr.end_column = std.fmt.parseInt(usize, col_, 10) catch 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| { for (dests.items) |dest| {