CVSROOT:        /cvs
Module name:    src
Changes by:     schwa...@cvs.openbsd.org        2025/05/18 15:18:27

Modified files:
        bin/ksh        : vi.c 

Log message:
In VI editing mode, rewrite that part of the cursor movement function
that moves the cursor to the right.
Simplify the code by making sure that the column number index "ci"
and the byte pointer "wb" always point to the same character; that's
achieved by incrementing ci at the beginning and wb at the end of the loop.
This simplification allows using one call to isu8cont() rather than two.

The rewrite was needed because command lines starting
with a UTF-8 continuation byte were mishandled in two ways.
* If the target column is right after the prompt (col == pwidth),
do not enter the printing loop at all, not even if the first byte
is a UTF-8 continuation byte.
* If the target column is further to the right (col > pwidth),
let the first byte always advance the column (ci++), even if it
is a UTF-8 continuation byte.

Issues found while studying test input suggested by lucas@.
OK lucas@.

Reply via email to