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