aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-06-16 14:45:10 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2021-06-16 23:53:03 +0200
commitf1d21b743485defb39fada03b27878efb1e2f7e3 (patch)
treed46277dd061921c86e97571bf96f899391501baf
parente7a8e8e30c31977476ab3be2fadb38c2bcb92482 (diff)
downloadbusybox-w32-f1d21b743485defb39fada03b27878efb1e2f7e3.tar.gz
busybox-w32-f1d21b743485defb39fada03b27878efb1e2f7e3.tar.bz2
busybox-w32-f1d21b743485defb39fada03b27878efb1e2f7e3.zip
vi: keep autoindent if line isn't empty
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> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/vi.c2
1 files changed, 1 insertions, 1 deletions
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'
2147#if ENABLE_FEATURE_VI_SETOPTS 2147#if ENABLE_FEATURE_VI_SETOPTS
2148 if (autoindent) { 2148 if (autoindent) {
2149 len = indent_len(bol); 2149 len = indent_len(bol);
2150 if (len && get_column(bol + len) == indentcol) { 2150 if (len && get_column(bol + len) == indentcol && bol[len] == '\n') {
2151 // remove autoindent from otherwise empty line 2151 // remove autoindent from otherwise empty line
2152 text_hole_delete(bol, bol + len - 1, undo); 2152 text_hole_delete(bol, bol + len - 1, undo);
2153 p = bol; 2153 p = bol;