mirror of
https://github.com/openbsd/src.git
synced 2026-05-01 17:46:35 +00:00
Simple fix to prevvent the "delete to EOL" (D) command in VI mode
from corrupting the cursor position when the last character remaining on the line is UTF-8. Instead of putting the cursor on the last byte, let the loop after the end of the "select" block put it at the beginning of the last character. Tested by Walter Alejandro Iglesias <wai at roquesor dot com>, and no objection was raised when shown on tech@.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: vi.c,v 1.62 2025/04/25 18:28:33 schwarze Exp $ */
|
||||
/* $OpenBSD: vi.c,v 1.63 2025/04/27 17:06:58 schwarze Exp $ */
|
||||
|
||||
/*
|
||||
* vi command editing
|
||||
@@ -865,8 +865,6 @@ vi_cmd(int argcnt, const char *cmd)
|
||||
case 'D':
|
||||
yank_range(es->cursor, es->linelen);
|
||||
del_range(es->cursor, es->linelen);
|
||||
if (es->cursor != 0)
|
||||
es->cursor--;
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $OpenBSD: vi.sh,v 1.11 2025/04/25 18:28:33 schwarze Exp $
|
||||
# $OpenBSD: vi.sh,v 1.12 2025/04/27 17:06:58 schwarze Exp $
|
||||
#
|
||||
# Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
|
||||
# Copyright (c) 2017 Anton Lindqvist <anton@openbsd.org>
|
||||
@@ -72,6 +72,8 @@ testseq "one 2.0\0033BD" " # one 2.0\b\b\b \b\b\b\b"
|
||||
testseq "one ab.cd\0033bDa.\00332bD" \
|
||||
" # one ab.cd\b\b \b\b\b..\b\b\b\b \b\b\b\b\b"
|
||||
testseq "one two\0033bCrep" " # one two\b\b\b \b\b\brep"
|
||||
testseq "\0302\0251\0303\0200a\0033DP" \
|
||||
" # \0302\0251\0303\0200a\b \b\ba\0303\0200\b\b"
|
||||
|
||||
# c: Change region.
|
||||
testseq "one two\0033cbrep" " # one two\b\b\bo \b\b\bro\beo\bpo\b"
|
||||
|
||||
Reference in New Issue
Block a user