Using vi mode in ksh I noticed that the command endword (vi.c) gets
staked when the last character in a word is a UTF-8 character.

To reproduce:

In the line bellow, using vi mode, first move your cursor to the first
character, then hit "e" several times.  You'll see the cursor get
stacked in the euro sign.

  $ word word€ word
             ^ this is an euro sign.


The following diff is one of my intuitive C newbie solutions, some
expert will surely find a better one.


Index: vi.c
===================================================================
RCS file: /cvs/src/bin/ksh/vi.c,v
diff -u -p -r1.60 vi.c
--- vi.c        12 Mar 2021 02:10:25 -0000      1.60
+++ vi.c        3 Apr 2025 12:44:33 -0000
@@ -1195,8 +1195,11 @@ domove(int argcnt, const char *cmd, int 
                        return -1;
                ncursor = (*cmd == 'e' ? endword : Endword)(argcnt);
                if (!sub)
-                       while (isu8cont((unsigned char)es->cbuf[--ncursor]))
+                       while (isu8cont((unsigned char)es->cbuf[--ncursor])) {
+                               if (!isspace(isu8cont((unsigned 
char)es->cursor) + 1))
+                                       break;
                                continue;
+                       }
                break;
 
        case 'f':


-- 
Walter

Reply via email to