summaryrefslogtreecommitdiff
path: root/Src/Zle/zle_vi.c
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2014-11-15 21:27:44 +0100
committerOliver Kiddle <opk@zsh.org>2014-11-15 21:27:44 +0100
commitf26abf3a1733b31e2f24c15b07e7c64b1659d95d (patch)
tree4fe6f8bed1fd74dcfa7857d40f9882cb762da9bc /Src/Zle/zle_vi.c
parent8505837f89e153bbfccf8e4763a3408c09062216 (diff)
downloadzsh-f26abf3a1733b31e2f24c15b07e7c64b1659d95d.tar.gz
zsh-f26abf3a1733b31e2f24c15b07e7c64b1659d95d.zip
33695: fix various vi-indent problems and vi-swap-case on a blank line
Diffstat (limited to 'Src/Zle/zle_vi.c')
-rw-r--r--Src/Zle/zle_vi.c14
1 files changed, 10 insertions, 4 deletions
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]);