fix(compatibility): do not crash when padding before wide char (#540)

* fix(compatibility): do not crash when padding before wide char

* style(clippy): make less clear because clippy
This commit is contained in:
Aram Drevekenin 2021-05-28 17:30:23 +02:00 committed by GitHub
parent 774858f240
commit 12709e3e48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1769,6 +1769,8 @@ impl Row {
let mut replace_with = vec![terminal_character; to + width_of_current_character];
if to_position_accounting_for_widechars > self.columns.len() {
self.columns.clear();
} else if to_position_accounting_for_widechars >= self.columns.len() {
drop(self.columns.drain(0..to_position_accounting_for_widechars));
} else {
drop(self.columns.drain(0..=to_position_accounting_for_widechars));
}