File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,10 +58,12 @@ STATIC char *str_dup_maybe(const char *str) {
5858 return s2 ;
5959}
6060
61- STATIC int count_cont_bytes (char * start , char * end ) {
61+ STATIC size_t count_cont_bytes (char * start , char * end ) {
6262 int count = 0 ;
6363 for (char * pos = start ; pos < end ; pos ++ ) {
64- count += UTF8_IS_CONT (* pos );
64+ if (UTF8_IS_CONT (* pos )) {
65+ count ++ ;
66+ }
6567 }
6668 return count ;
6769}
@@ -108,7 +110,7 @@ typedef struct _readline_t {
108110STATIC readline_t rl ;
109111
110112int readline_process_char (int c ) {
111- size_t last_line_len = rl .line -> len ;
113+ size_t last_line_len = utf8_charlen (( byte * ) rl .line -> buf , rl . line -> len ) ;
112114 int cont_chars = 0 ;
113115 int redraw_step_back = 0 ;
114116 bool redraw_from_cursor = false;
@@ -380,7 +382,7 @@ int readline_process_char(int c) {
380382 rl .cursor_pos -= redraw_step_back ;
381383 }
382384 if (redraw_from_cursor ) {
383- if (rl .line -> len < last_line_len ) {
385+ if (utf8_charlen (( byte * ) rl .line -> buf , rl . line -> len ) < last_line_len ) {
384386 // erase old chars
385387 mp_hal_erase_line_from_cursor (last_line_len - rl .cursor_pos );
386388 }
You can’t perform that action at this time.
0 commit comments