[git commit] vi: make cursor positioning more vi compatible
Denys Vlasenko
vda.linux at googlemail.com
Wed Jun 2 04:16:36 UTC 2021
commit: https://git.busybox.net/busybox/commit/?id=d95f89ec576c5a0ecba24ead7f012f1fd8ea7b9b
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
Commit 24effc7a3 (vi: cursor positioning after whole-line 'y')
tried to save a few bytes by treating whole-line deletion the
same as whole-line yank. If the deletion removed the last lines
of the file the cursor was left beyond the end of the file.
Revert the part of the commit related to whole-line deletion.
Position the cursor on the first non-whitespace character of the
line when whole lines are 'put'.
function old new delta
do_cmd 4759 4781 +22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 22/0) Total: 22 bytes
Signed-off-by: Ron Yorston <rmy at pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
editors/vi.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/editors/vi.c b/editors/vi.c
index 4a7f8c3c2..c4f3b9660 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -3717,6 +3717,7 @@ static void do_cmd(int c)
# endif
} while (--cmdcnt > 0);
dot += cnt;
+ dot_skip_over_ws();
# if ENABLE_FEATURE_VI_YANKMARK && ENABLE_FEATURE_VI_VERBOSE_STATUS
yank_status("Put", p, i);
# endif
@@ -4172,6 +4173,9 @@ static void do_cmd(int c)
if (dot != (end-1)) {
dot_prev();
}
+ } else if (c == 'd') {
+ dot_begin();
+ dot_skip_over_ws();
} else {
dot = save_dot;
}
More information about the busybox-cvs
mailing list