[git commit] vi: don't move cursor when yanking whole lines

Denys Vlasenko vda.linux at googlemail.com
Thu Apr 15 11:09:12 UTC 2021


commit: https://git.busybox.net/busybox/commit/?id=d6e653d667bc1eb343014508a8bddb3dd4945f78
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

When whole lines are yanked using 'yy' or 'Y' vi doesn't change the
cursor position.  Make BusyBox vi do the same.

function                                             old     new   delta
do_cmd                                              4776    4786     +10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 10/0)               Total: 10 bytes

Signed-off-by: Ron Yorston <rmy at pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 editors/vi.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/editors/vi.c b/editors/vi.c
index d20481fbd..780c81234 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -3934,6 +3934,7 @@ static void do_cmd(int c)
 # endif
 		if (c == 'y' || c == 'Y')
 			yf = YANKONLY;
+		save_dot = dot;
 #endif
 		// determine range, and whether it spans lines
 		buftype = find_range(&p, &q, c);
@@ -3951,6 +3952,11 @@ static void do_cmd(int c)
 				dot_begin();
 				dot_skip_over_ws();
 			}
+#if ENABLE_FEATURE_VI_YANKMARK
+			else /* (c == 'y' || c == 'Y') */ {
+				dot = save_dot;
+			}
+#endif
 		}
 		// if CHANGING, not deleting, start inserting after the delete
 		if (c == 'c') {


More information about the busybox-cvs mailing list