File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -336,8 +336,10 @@ impl Term {
336
336
loop {
337
337
match slf. read_key ( ) ? {
338
338
Key :: Backspace => {
339
- if prefix_len < chars. len ( ) && chars. pop ( ) . is_some ( ) {
340
- slf. clear_chars ( 1 ) ?;
339
+ if prefix_len < chars. len ( ) {
340
+ if let Some ( ch) = chars. pop ( ) {
341
+ slf. clear_chars ( crate :: utils:: char_width ( ch) ) ?;
342
+ }
341
343
}
342
344
slf. flush ( ) ?;
343
345
}
Original file line number Diff line number Diff line change @@ -719,7 +719,7 @@ fn str_width(s: &str) -> usize {
719
719
}
720
720
721
721
#[ cfg( feature = "ansi-parsing" ) ]
722
- fn char_width ( c : char ) -> usize {
722
+ pub ( crate ) fn char_width ( c : char ) -> usize {
723
723
#[ cfg( feature = "unicode-width" ) ]
724
724
{
725
725
use unicode_width:: UnicodeWidthChar ;
@@ -732,6 +732,11 @@ fn char_width(c: char) -> usize {
732
732
}
733
733
}
734
734
735
+ #[ cfg( not( feature = "ansi-parsing" ) ) ]
736
+ pub ( crate ) fn char_width ( _c : char ) -> usize {
737
+ 1
738
+ }
739
+
735
740
/// Truncates a string to a certain number of characters.
736
741
///
737
742
/// This ensures that escape codes are not screwed up in the process.
You canβt perform that action at this time.
0 commit comments