PR comments addressed for line range +delta syntax

This commit is contained in:
Bojan Durdevic 2021-08-22 11:59:24 -04:00 committed by David Peter
parent 0748783404
commit c86a179412
2 changed files with 3 additions and 3 deletions

View file

@ -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

View file

@ -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()?