diff --git a/src/internal/address/resolve.cc b/src/internal/address/resolve.cc index 249bc2b..19949df 100644 --- a/src/internal/address/resolve.cc +++ b/src/internal/address/resolve.cc @@ -18,23 +18,29 @@ uint64_t Address::resolve(BEd &ctx) { } else if constexpr (std::is_same_v) { line = addr.i; } else if constexpr (std::is_same_v) { + uint64_t current_line = ctx.active->line; + if (ctx.active->vase.lines() > 0 && current_line == 0) + current_line = 1; if (addr.dir == Direction::Forward) { if (ctx.active->parser) { - if (ctx.active->line == 0) - ctx.active->line = 1; - line = ctx.active->parser->next_closing(ctx.active->line - 1) + 1; + uint64_t closing = ctx.active->parser->next_closing(current_line - 1); + if (closing == UINT64_MAX) + line = ctx.active->vase.lines(); + else + line = closing + 1; + } else { + line = current_line + 10; if (line > ctx.active->vase.lines()) line = ctx.active->vase.lines(); - } else { - line = ctx.active->line + 10; } } else { if (ctx.active->parser) { - if (ctx.active->line == 0) - ctx.active->line = 1; - line = ctx.active->parser->prev_opening(ctx.active->line - 1) + 1; + line = ctx.active->parser->prev_opening(current_line - 1) + 1; } else { - line = ctx.active->line - 10; + if (current_line > 10) + line = current_line - 10; + else + line = 0; } } } else { diff --git a/src/internal/commands/commands.cc b/src/internal/commands/commands.cc index bbb9d63..75644a6 100644 --- a/src/internal/commands/commands.cc +++ b/src/internal/commands/commands.cc @@ -107,7 +107,7 @@ void Command::register_posix(BEd &ctx) { .address_mode = Command::AddressMode::Single, .suffix = Command::SuffixKind::Suffix, .desc = "Print line number", - .accept_zero = false, + .accept_zero = true, .handle = [](BEd &ctx, std::span addresses, std::string_view) { if (!addresses.size()) std::cout << ctx.active->vase.lines() << std::endl;