mirror of
https://github.com/sharkdp/bat.git
synced 2025-06-18 22:35:51 +01:00
use saturating substraction to calculate Line ranges
This commit is contained in:
@ -177,7 +177,8 @@ impl<'b> Controller<'b> {
|
|||||||
if let Some(line_changes) = line_changes {
|
if let Some(line_changes) = line_changes {
|
||||||
for &line in line_changes.keys() {
|
for &line in line_changes.keys() {
|
||||||
let line = line as usize;
|
let line = line as usize;
|
||||||
line_ranges.push(LineRange::new(line - context, line + context));
|
line_ranges
|
||||||
|
.push(LineRange::new(line.saturating_sub(context), line + context));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user