correctly handle multiple tabs in one line
commite7df748b6db18fd47c4cf4757ac0193cce98298a
authorPatrick Hilhorst <git@hilhorst.be>
dateMon 24 Jan 2022, 12:40 (5 years ago)
parent67124f8
src/preprocessor.rs+1
@@ -66,6 +66,7 @@ pub fn replace_nonprintable(input: &[u8], tab_width: usize) -> String {
6666 // tab
6767 '\t' => {
6868 let tab_stop = tab_width - ((line_idx - 1) % tab_width);
69+ line_idx = 0;
6970 if tab_stop == 1 {
7071 output.push('↹');
7172 } else {
tests/integration_tests.rs+2−2
@@ -1227,7 +1227,7 @@ fn show_all_tabstops() {
12271227 .assert()
12281228 .success()
12291229 .stdout(
1230− "├──┤1├┤2├──┤3├┤4␊
1230+ "├──┤1├─┤2├─┤3├─┤4␊
123112311├─┤?␊
1232123222├┤?␊
12331233333↹?␊
@@ -1250,7 +1250,7 @@ fn show_all_tabstops_long() {
12501250 .assert()
12511251 .success()
12521252 .stdout(
1253− "├──────┤1├────┤2├──┤3├┤4␊
1253+ "├──────┤1├─────┤2├─────┤3├─────┤4␊
125412541├─────┤?␊
1255125522├────┤?␊
12561256333├───┤?␊