From f26abf3a1733b31e2f24c15b07e7c64b1659d95d Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Sat, 15 Nov 2014 21:27:44 +0100 Subject: 33695: fix various vi-indent problems and vi-swap-case on a blank line --- Src/Zle/zle_vi.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'Src/Zle') diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c index a60caa2b4..68b1c9211 100644 --- a/Src/Zle/zle_vi.c +++ b/Src/Zle/zle_vi.c @@ -700,10 +700,14 @@ viindent(UNUSED(char **args)) } oldcs = zlecs; /* add a tab to the beginning of each line within range */ - while (zlecs < c2) { - spaceinline(1); - zleline[zlecs] = '\t'; - zlecs = findeol() + 1; + while (zlecs <= c2 + 1) { + if (zleline[zlecs] == '\n') { /* leave blank lines alone */ + ++zlecs; + } else { + spaceinline(1); + zleline[zlecs] = '\t'; + zlecs = findeol() + 1; + } } /* go back to the first line of the range */ zlecs = oldcs; @@ -830,6 +834,8 @@ viswapcase(UNUSED(char **args)) if (n < 1) return 1; eol = findeol(); + if (zlecs == eol) + return 1; while (zlecs < eol && n--) { if (ZC_ilower(zleline[zlecs])) zleline[zlecs] = ZC_toupper(zleline[zlecs]); -- cgit 1.4.1