Test longest row only when tabs are not present or the tab size is 1

This is because the longest row calculation is best-effort at the moment,
since this information is not indexed in the `TabMap`.
This commit is contained in:
Antonio Scandurra 2021-11-18 10:41:47 +01:00
parent 5a9dea5299
commit 572e571927
2 changed files with 34 additions and 26 deletions

View file

@ -506,14 +506,14 @@ mod tests {
.map(|c| c.text)
.collect::<String>()
);
assert_eq!(
TextSummary {
longest_row: expected_summary.longest_row,
longest_row_chars: expected_summary.longest_row_chars,
..tabs_snapshot.text_summary_for_range(start..end)
},
expected_summary,
);
let mut actual_summary = tabs_snapshot.text_summary_for_range(start..end);
if tab_size > 1 && folds_snapshot.text().contains('\t') {
actual_summary.longest_row = expected_summary.longest_row;
actual_summary.longest_row_chars = expected_summary.longest_row_chars;
}
assert_eq!(actual_summary, expected_summary,);
}
}
}

View file

@ -1214,6 +1214,13 @@ mod tests {
log::info!("{} summary: {:?}", ix, item.summary.output,);
}
if tab_size == 1
|| !wrapped_snapshot
.tab_snapshot
.fold_snapshot
.text()
.contains('\t')
{
let mut expected_longest_rows = Vec::new();
let mut longest_line_len = -1;
for (row, line) in expected_text.split('\n').enumerate() {
@ -1236,6 +1243,7 @@ mod tests {
)
}
}
}
let mut initial_text = Rope::from(initial_snapshot.text().as_str());
for (snapshot, patch) in edits {