diff options
author | Oliver Kiddle <opk@zsh.org> | 2015-05-04 21:51:06 +0200 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2015-05-04 21:51:06 +0200 |
commit | 9afbe051b9d261eb5703fdb3403abac41ce5f816 (patch) | |
tree | 7edcb2b98f9b124237d39c3cb9fe70019847a4f8 /Src | |
parent | 1e6fb1a4f0586e62996bb19c9c07bc3c8d24659c (diff) | |
download | zsh-9afbe051b9d261eb5703fdb3403abac41ce5f816.tar.gz zsh-9afbe051b9d261eb5703fdb3403abac41ce5f816.tar.xz zsh-9afbe051b9d261eb5703fdb3403abac41ce5f816.zip |
35029: improvements to newline handling for vi-mode word movement
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Zle/zle_word.c | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/Src/Zle/zle_word.c b/Src/Zle/zle_word.c index cb5e5dbe5..2e6d75e86 100644 --- a/Src/Zle/zle_word.c +++ b/Src/Zle/zle_word.c @@ -80,16 +80,21 @@ viforwardword(char **args) return ret; } while (n--) { + int nl; if (Z_vialnum(zleline[zlecs])) while (zlecs != zlell && Z_vialnum(zleline[zlecs])) INCCS(); else - while (zlecs != zlell && !Z_vialnum(zleline[zlecs]) && !ZC_iblank(zleline[zlecs])) + while (zlecs != zlell && !Z_vialnum(zleline[zlecs]) && + !ZC_inblank(zleline[zlecs])) INCCS(); if (wordflag && !n) return 0; - while (zlecs != zlell && ZC_inblank(zleline[zlecs])) + nl = (zleline[zlecs] == ZWC('\n')); + while (zlecs != zlell && nl < 2 && ZC_inblank(zleline[zlecs])) { INCCS(); + nl += (zleline[zlecs] == ZWC('\n')); + } } return 0; } @@ -108,12 +113,16 @@ viforwardblankword(char **args) return ret; } while (n--) { - while (zlecs != zlell && !ZC_iblank(zleline[zlecs])) + int nl; + while (zlecs != zlell && !ZC_inblank(zleline[zlecs])) INCCS(); if (wordflag && !n) return 0; - while (zlecs != zlell && ZC_iblank(zleline[zlecs])) + nl = (zleline[zlecs] == ZWC('\n')); + while (zlecs != zlell && nl < 2 && ZC_inblank(zleline[zlecs])) { INCCS(); + nl += (zleline[zlecs] == ZWC('\n')); + } } return 0; } @@ -159,14 +168,14 @@ viforwardblankwordend(UNUSED(char **args)) while (zlecs != zlell) { int pos = zlecs; INCPOS(pos); - if (!ZC_iblank(zleline[pos])) + if (!ZC_inblank(zleline[pos])) break; zlecs = pos; } while (zlecs != zlell) { int pos = zlecs; INCPOS(pos); - if (ZC_iblank(zleline[pos])) + if (ZC_inblank(zleline[pos])) break; zlecs = pos; } @@ -216,7 +225,7 @@ viforwardwordend(char **args) if (zlecs == zlell) break; INCPOS(pos); - if (Z_vialnum(zleline[pos]) || ZC_iblank(zleline[pos])) + if (Z_vialnum(zleline[pos]) || ZC_inblank(zleline[pos])) break; } } @@ -273,16 +282,19 @@ vibackwardword(char **args) return ret; } while (n--) { + int nl = 0; while (zlecs) { - int pos = zlecs; - DECPOS(pos); - if (!ZC_iblank(zleline[pos])) + DECCS(); + if (!ZC_inblank(zleline[zlecs])) break; - zlecs = pos; + nl += (zleline[zlecs] == ZWC('\n')); + if (nl == 2) { + INCCS(); + break; + } } if (zlecs) { int pos = zlecs; - DECPOS(pos); if (Z_vialnum(zleline[pos])) { for (;;) { zlecs = pos; @@ -298,7 +310,7 @@ vibackwardword(char **args) if (zlecs == 0) break; DECPOS(pos); - if (Z_vialnum(zleline[pos]) || ZC_iblank(zleline[pos])) + if (Z_vialnum(zleline[pos]) || ZC_inblank(zleline[pos])) break; } } @@ -321,17 +333,20 @@ vibackwardblankword(char **args) return ret; } while (n--) { + int nl = 0; while (zlecs) { int pos = zlecs; DECPOS(pos); - if (!ZC_iblank(zleline[pos])) + if (!ZC_inblank(zleline[pos])) break; + nl += (zleline[pos] == ZWC('\n')); + if (nl == 2) break; zlecs = pos; } while (zlecs) { int pos = zlecs; DECPOS(pos); - if (ZC_iblank(zleline[pos])) + if (ZC_inblank(zleline[pos])) break; zlecs = pos; } @@ -356,7 +371,7 @@ vibackwardwordend(char **args) int start = 0; if (Z_vialnum(zleline[zlecs])) start = 1; - else if (!ZC_iblank(zleline[zlecs])) + else if (!ZC_inblank(zleline[zlecs])) start = 2; DECCS(); while (zlecs) { @@ -387,9 +402,9 @@ vibackwardblankwordend(char **args) return ret; } while (n--) { - while (zlecs && !ZC_iblank(zleline[zlecs])) + while (zlecs && !ZC_inblank(zleline[zlecs])) DECCS(); - while (zlecs && ZC_iblank(zleline[zlecs])) + while (zlecs && ZC_inblank(zleline[zlecs])) DECCS(); } return 0; |