diff options
author | 2017-05-28 07:27:01 +0000 | |
---|---|---|
committer | 2017-05-28 07:27:01 +0000 | |
commit | acf1a5765cfef72ac6162752cb9d1c372298c321 (patch) | |
tree | a9ebee1f024b57eea4292d41c5104572bec26d4e | |
parent | print_ioctl() is unused if not debugging. Found with clang, after (diff) | |
download | wireguard-openbsd-acf1a5765cfef72ac6162752cb9d1c372298c321.tar.xz wireguard-openbsd-acf1a5765cfef72ac6162752cb9d1c372298c321.zip |
Fix cursor position while removing characters from the command line.
While here, remove a condition that becomes redundant.
ok schwarze@ tb@
-rw-r--r-- | bin/ksh/vi.c | 8 | ||||
-rw-r--r-- | regress/bin/ksh/vi/vi.sh | 1 |
2 files changed, 6 insertions, 3 deletions
diff --git a/bin/ksh/vi.c b/bin/ksh/vi.c index 8bfb334d145..fd6c32507ad 100644 --- a/bin/ksh/vi.c +++ b/bin/ksh/vi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vi.c,v 1.44 2016/10/17 18:39:43 schwarze Exp $ */ +/* $OpenBSD: vi.c,v 1.45 2017/05/28 07:27:01 anton Exp $ */ /* * vi command editing @@ -1154,8 +1154,10 @@ vi_cmd(int argcnt, const char *cmd) expand_word(1); break; } - if (insert == 0 && es->cursor != 0 && es->cursor >= es->linelen) - es->cursor--; + if (insert == 0 && es->cursor >= es->linelen) + while (es->cursor > 0) + if (!isu8cont(es->cbuf[--es->cursor])) + break; } return 0; } diff --git a/regress/bin/ksh/vi/vi.sh b/regress/bin/ksh/vi/vi.sh index 13f38991d8c..710528a8a85 100644 --- a/regress/bin/ksh/vi/vi.sh +++ b/regress/bin/ksh/vi/vi.sh @@ -168,6 +168,7 @@ testseq "abcd\00332X" " $ abcd\b\b\bd \b\b\b\r\nad" # x: Delete character. # |: Move to column. testseq "abcd\00332|2x" " $ abcd\b\b\bd \b\b\b\r\nad" +testseq "\0303\0266a\0033xx" " $ \0303\0266a\b \b\b \b\b\r" # Y: Yank to end of line. testseq "abcd\0033hYp" " $ abcd\b\bccdd\b\b\r\nabccdd" |