From 7228a604b0a8de6ff79c108dd6c308c2d38220db Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 17 Sep 2025 22:46:35 +0200 Subject: [PATCH] feat: add byte offset support to vim style '+' cli arguments This adds support for using `+b{offset}` on the command line. --- src/main.zig | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/main.zig b/src/main.zig index e914235..ec12528 100644 --- a/src/main.zig +++ b/src/main.zig @@ -245,19 +245,34 @@ pub fn main() anyerror!void { defer links.deinit(); var prev: ?*file_link.Dest = null; var line_next: ?usize = null; + var offset_next: ?usize = null; for (positional_args.items) |arg| { if (arg.len == 0) continue; if (!args.literal and arg[0] == '+') { - const line = try std.fmt.parseInt(usize, arg[1..], 10); - if (prev) |p| switch (p.*) { - .file => |*file| { - file.line = line; - continue; - }, - else => {}, - }; - line_next = line; + if (arg.len > 2 and arg[1] == 'b') { + const offset = try std.fmt.parseInt(usize, arg[2..], 10); + if (prev) |p| switch (p.*) { + .file => |*file| { + file.offset = offset; + continue; + }, + else => {}, + }; + offset_next = offset; + line_next = null; + } else { + const line = try std.fmt.parseInt(usize, arg[1..], 10); + if (prev) |p| switch (p.*) { + .file => |*file| { + file.line = line; + continue; + }, + else => {}, + }; + line_next = line; + offset_next = null; + } continue; } @@ -274,6 +289,15 @@ pub fn main() anyerror!void { else => {}, } } + if (offset_next) |offset| { + switch (curr.*) { + .file => |*file| { + file.offset = offset; + offset_next = null; + }, + else => {}, + } + } } var have_project = false;