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 {
336336 loop {
337337 match slf. read_key ( ) ? {
338338 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+ }
341343 }
342344 slf. flush ( ) ?;
343345 }
Original file line number Diff line number Diff line change @@ -719,7 +719,7 @@ fn str_width(s: &str) -> usize {
719719}
720720
721721#[ cfg( feature = "ansi-parsing" ) ]
722- fn char_width ( c : char ) -> usize {
722+ pub ( crate ) fn char_width ( c : char ) -> usize {
723723 #[ cfg( feature = "unicode-width" ) ]
724724 {
725725 use unicode_width:: UnicodeWidthChar ;
@@ -732,6 +732,11 @@ fn char_width(c: char) -> usize {
732732 }
733733}
734734
735+ #[ cfg( not( feature = "ansi-parsing" ) ) ]
736+ pub ( crate ) fn char_width ( _c : char ) -> usize {
737+ 1
738+ }
739+
735740/// Truncates a string to a certain number of characters.
736741///
737742/// This ensures that escape codes are not screwed up in the process.
You canβt perform that action at this time.
0 commit comments