about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/zle_word.c51
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;