[PATCH] vi: don't right shift empty lines

Ron Yorston rmy at pobox.com
Fri Aug 20 07:25:07 UTC 2021


The right shift command ('>') shouldn't affect empty lines.

function                                             old     new   delta
do_cmd                                              4860    4894     +34
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 34/0)               Total: 34 bytes

Signed-off-by: Ron Yorston <rmy at pobox.com>
---
 editors/vi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/editors/vi.c b/editors/vi.c
index 3e1bd0820..6f8a87b70 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -4089,8 +4089,8 @@ static void do_cmd(int c)
 #endif
 					}
 				}
-			} else /* if (c == '>') */ {
-				// shift right -- add tab or tabstop spaces
+			} else if (/* c == '>' && */ p != end_line(p)) {
+				// shift right -- add tab or tabstop spaces on non-empty lines
 				char_insert(p, '\t', allow_undo);
 			}
 #if ENABLE_FEATURE_VI_UNDO
-- 
2.31.1




More information about the busybox mailing list