mirror of
https://github.com/sharkdp/bat
synced 2024-11-15 00:12:57 +00:00
Rename enum field
This commit is contained in:
parent
06b7be7ee9
commit
4855a47105
@ -106,7 +106,7 @@ impl<'b> Controller<'b> {
|
|||||||
|
|
||||||
while reader.read_line(&mut line_buffer)? {
|
while reader.read_line(&mut line_buffer)? {
|
||||||
match line_ranges.check(line_number) {
|
match line_ranges.check(line_number) {
|
||||||
RangeCheckResult::OutsideRange => {
|
RangeCheckResult::BeforeOrBetweenRanges => {
|
||||||
// Call the printer in case we need to call the syntax highlighter
|
// Call the printer in case we need to call the syntax highlighter
|
||||||
// for this line. However, set `out_of_range` to `true`.
|
// for this line. However, set `out_of_range` to `true`.
|
||||||
printer.print_line(true, writer, line_number, &line_buffer)?;
|
printer.print_line(true, writer, line_number, &line_buffer)?;
|
||||||
|
@ -99,7 +99,7 @@ pub enum RangeCheckResult {
|
|||||||
InRange,
|
InRange,
|
||||||
|
|
||||||
// Before the first range or within two ranges
|
// Before the first range or within two ranges
|
||||||
OutsideRange,
|
BeforeOrBetweenRanges,
|
||||||
|
|
||||||
// Line number is outside of all ranges and larger than the last range.
|
// Line number is outside of all ranges and larger than the last range.
|
||||||
AfterLastRange,
|
AfterLastRange,
|
||||||
@ -131,10 +131,10 @@ impl LineRanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn check(&self, line: usize) -> RangeCheckResult {
|
pub fn check(&self, line: usize) -> RangeCheckResult {
|
||||||
if self.ranges.is_empty() | self.ranges.iter().any(|r| r.is_inside(line)) {
|
if self.ranges.is_empty() || self.ranges.iter().any(|r| r.is_inside(line)) {
|
||||||
RangeCheckResult::InRange
|
RangeCheckResult::InRange
|
||||||
} else if line < self.largest_upper_bound {
|
} else if line < self.largest_upper_bound {
|
||||||
RangeCheckResult::OutsideRange
|
RangeCheckResult::BeforeOrBetweenRanges
|
||||||
} else {
|
} else {
|
||||||
RangeCheckResult::AfterLastRange
|
RangeCheckResult::AfterLastRange
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ fn ranges(rs: &[&str]) -> LineRanges {
|
|||||||
fn test_ranges_simple() {
|
fn test_ranges_simple() {
|
||||||
let ranges = ranges(&["3:8"]);
|
let ranges = ranges(&["3:8"]);
|
||||||
|
|
||||||
assert_eq!(RangeCheckResult::OutsideRange, ranges.check(2));
|
assert_eq!(RangeCheckResult::BeforeOrBetweenRanges, ranges.check(2));
|
||||||
assert_eq!(RangeCheckResult::InRange, ranges.check(5));
|
assert_eq!(RangeCheckResult::InRange, ranges.check(5));
|
||||||
assert_eq!(RangeCheckResult::AfterLastRange, ranges.check(9));
|
assert_eq!(RangeCheckResult::AfterLastRange, ranges.check(9));
|
||||||
}
|
}
|
||||||
@ -159,11 +159,11 @@ fn test_ranges_simple() {
|
|||||||
fn test_ranges_advanced() {
|
fn test_ranges_advanced() {
|
||||||
let ranges = ranges(&["3:8", "11:20", "25:30"]);
|
let ranges = ranges(&["3:8", "11:20", "25:30"]);
|
||||||
|
|
||||||
assert_eq!(RangeCheckResult::OutsideRange, ranges.check(2));
|
assert_eq!(RangeCheckResult::BeforeOrBetweenRanges, ranges.check(2));
|
||||||
assert_eq!(RangeCheckResult::InRange, ranges.check(5));
|
assert_eq!(RangeCheckResult::InRange, ranges.check(5));
|
||||||
assert_eq!(RangeCheckResult::OutsideRange, ranges.check(9));
|
assert_eq!(RangeCheckResult::BeforeOrBetweenRanges, ranges.check(9));
|
||||||
assert_eq!(RangeCheckResult::InRange, ranges.check(11));
|
assert_eq!(RangeCheckResult::InRange, ranges.check(11));
|
||||||
assert_eq!(RangeCheckResult::OutsideRange, ranges.check(22));
|
assert_eq!(RangeCheckResult::BeforeOrBetweenRanges, ranges.check(22));
|
||||||
assert_eq!(RangeCheckResult::InRange, ranges.check(28));
|
assert_eq!(RangeCheckResult::InRange, ranges.check(28));
|
||||||
assert_eq!(RangeCheckResult::AfterLastRange, ranges.check(31));
|
assert_eq!(RangeCheckResult::AfterLastRange, ranges.check(31));
|
||||||
}
|
}
|
||||||
@ -182,7 +182,7 @@ fn test_ranges_open_low() {
|
|||||||
fn test_ranges_open_high() {
|
fn test_ranges_open_high() {
|
||||||
let ranges = ranges(&["3:", "2:5"]);
|
let ranges = ranges(&["3:", "2:5"]);
|
||||||
|
|
||||||
assert_eq!(RangeCheckResult::OutsideRange, ranges.check(1));
|
assert_eq!(RangeCheckResult::BeforeOrBetweenRanges, ranges.check(1));
|
||||||
assert_eq!(RangeCheckResult::InRange, ranges.check(3));
|
assert_eq!(RangeCheckResult::InRange, ranges.check(3));
|
||||||
assert_eq!(RangeCheckResult::InRange, ranges.check(5));
|
assert_eq!(RangeCheckResult::InRange, ranges.check(5));
|
||||||
assert_eq!(RangeCheckResult::InRange, ranges.check(9));
|
assert_eq!(RangeCheckResult::InRange, ranges.check(9));
|
||||||
|
Loading…
Reference in New Issue
Block a user