1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-03 03:42:26 +01:00

docs: 📚 update changelog for range context support

docs(CHANGELOG.md): 📚 add entry for context in line ranges and normalize list formatting
style(src/line_range.rs): 🎨 trim trailing whitespace in context parsing code
This commit is contained in:
John Cavanaugh
2025-07-15 16:25:28 -07:00
parent 6c13a98f01
commit dc2eae08a6
2 changed files with 43 additions and 53 deletions

View File

@@ -106,7 +106,7 @@ impl LineRange {
.map_err(|_| "Invalid line number in N::C format")?;
let context: usize = line_numbers[2].parse()
.map_err(|_| "Invalid context number in N::C format")?;
new_range.lower = RangeBound::Absolute(line_number.saturating_sub(context));
new_range.upper = RangeBound::Absolute(line_number.saturating_add(context));
} else {
@@ -117,7 +117,7 @@ impl LineRange {
.map_err(|_| "Invalid end line number in N:M:C format")?;
let context: usize = line_numbers[2].parse()
.map_err(|_| "Invalid context number in N:M:C format")?;
new_range.lower = RangeBound::Absolute(start_line.saturating_sub(context));
new_range.upper = RangeBound::Absolute(end_line.saturating_add(context));
}
@@ -319,12 +319,12 @@ fn test_parse_context_edge_cases() {
let range = LineRange::from("5::10").expect("Shouldn't fail on test!");
assert_eq!(RangeBound::Absolute(0), range.lower);
assert_eq!(RangeBound::Absolute(15), range.upper);
// Test with zero context
let range = LineRange::from("50::0").expect("Shouldn't fail on test!");
assert_eq!(RangeBound::Absolute(50), range.lower);
assert_eq!(RangeBound::Absolute(50), range.upper);
// Test range with zero context
let range = LineRange::from("30:40:0").expect("Shouldn't fail on test!");
assert_eq!(RangeBound::Absolute(30), range.lower);