From c86a1794121ab3460d496a55556abc17b03b71a2 Mon Sep 17 00:00:00 2001 From: Bojan Durdevic Date: Sun, 22 Aug 2021 11:59:24 -0400 Subject: [PATCH] PR comments addressed for line range +delta syntax --- CHANGELOG.md | 2 +- src/line_range.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec4d9e0881..8908b7ccf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## Features - `$BAT_CONFIG_DIR` is now a recognized environment variable. It has precedence over `$XDG_CONFIG_HOME`, see #1727 (@billrisher) -- Support for `x:+x` syntax in line ranges (e.g. `20:+10`). See #1810 (@bojan88) +- Support for `x:+delta` syntax in line ranges (e.g. `20:+10`). See #1810 (@bojan88) ## Bugfixes diff --git a/src/line_range.rs b/src/line_range.rs index d014d6881b..1cd3a20d41 100644 --- a/src/line_range.rs +++ b/src/line_range.rs @@ -48,10 +48,10 @@ impl LineRange { 2 => { new_range.lower = line_numbers[0].parse()?; - new_range.upper = if line_numbers[1].bytes().next().unwrap() == b'+' { + new_range.upper = if line_numbers[1].bytes().next() == Some(b'+') { let more_lines = &line_numbers[1][1..] .parse() - .map_err(|_| "Invalid line number after +")?; + .map_err(|_| "Invalid character after +")?; new_range.lower + more_lines } else { line_numbers[1].parse()?