[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [PATCH 1/3] vi: keep autoindent if line isn't empty
From: Ron Yorston <rmy () pobox ! com>
Date: 2021-06-16 13:45:10
Message-ID: 60ca0066.1lfk6ZFklB18dGeC%rmy () pobox ! com
[Download RAW message or body]
When ESC is entered to leave insert mode any autoindent should only
be removed if there's no content beyond the indent. This may be the
case if a line has been split by entering insert mode and then
entering a CR.
Add a check to ensure there's only a newline after the indent.
function old new delta
char_insert 912 929 +17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 17/0) Total: 17 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
---
editors/vi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/editors/vi.c b/editors/vi.c
index ba608fbd2..3daa0756b 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -2147,7 +2147,7 @@ static char *char_insert(char *p, char c, int undo) // insert the char c at 'p'
#if ENABLE_FEATURE_VI_SETOPTS
if (autoindent) {
len = indent_len(bol);
- if (len && get_column(bol + len) == indentcol) {
+ if (len && get_column(bol + len) == indentcol && bol[len] == '\n') {
// remove autoindent from otherwise empty line
text_hole_delete(bol, bol + len - 1, undo);
p = bol;
--
2.31.1
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic