1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
[33mcommit bbc4309d726819512f9b5fb72b187eeb63d34680[0m
Author: Johan Walles <johan.walles@gmail.com>
Date: Thu Dec 31 15:22:09 2020 +0100
Skip highlighting based on newline counts
If old text and new text have very different line counts, just do the
simplistic highlighting.
[2mdiff --git xsrc/refiner.rs xsrc/refiner.rs[0m
[2mindex d1ebdc1..40ae0df 100644[0m
[1m--- [0mxsrc/[1mrefiner.rs[0m
[1m+++ [0mxsrc/[1mrefiner.rs[0m
[36m@@ -15,8 +15,8 @@ [1muse diffus::{[0m
/// it.
const MAX_HIGHLIGHT_PERCENTAGE: usize = 30;
[31m-const [7mLARGE_BYTE_COUNT_CHANGE_PERCENT[27m: usize = 100;[0m
[31m-const [7mSMALL_BYTE_COUNT_CHANGE[27m: usize = 10;[0m
[32m+const [7mLARGE_COUNT_CHANGE_PERCENT[27m: usize = 100;[0m
[32m+const [7mSMALL_COUNT_CHANGE[27m: usize = 10;[0m
/// Format old and new lines in OLD and NEW colors.
///
[36m@@ -55,11 +55,14 @@ [1mpub fn format(old_text: &str, new_text: &str) -> Vec<String> {[0m
return simple_format(old_text, new_text);
}
[31m- // [7mThis check makes[27m us faster, please use the benchmark.py script before and[0m
[31m- // after if you change this.[0m
[32m+ // [7mThese checks make[27m us faster, please use the benchmark.py script before[0m
[32m+ // and after if you change this.[0m
if is_large_byte_count_change(old_text, new_text) {
return simple_format(old_text, new_text);
}
[32m+ if is_large_newline_count_change(old_text, new_text) {[0m
[32m+ return simple_format(old_text, new_text);[0m
[32m+ }[0m
// Find diffs between adds and removals
let mut old_collector = TokenCollector::create(StyledToken::new("-".to_string(), Style::Old));
|