about summary refs log tree commit diff
path: root/Src/Zle/zle_hist.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Zle/zle_hist.c')
-rw-r--r--Src/Zle/zle_hist.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index 54c103f60..85c149929 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -111,7 +111,7 @@ zlinecmp(const char *histp, const char *inputp)
     mbstate_t hstate, istate;
 #endif
 
-    while (*hptr == *iptr) {
+    while (*iptr && *hptr == *iptr) {
 	hptr++;
 	iptr++;
     }
@@ -470,13 +470,15 @@ historysearchbackward(char **args)
     if (!(he = quietgethist(histline)))
 	return 1;
 
+    metafy_line();
     while ((he = movehistent(he, -1, hist_skip_flags))) {
 	if (isset(HISTFINDNODUPS) && he->node.flags & HIST_DUP)
 	    continue;
 	zt = GETZLETEXT(he);
 	if (zlinecmp(zt, str) < 0 &&
-	    (*args || strcmp(zt, str) != 0)) {
+	    (*args || strcmp(zt, zlemetaline) != 0)) {
 	    if (--n <= 0) {
+		unmetafy_line();
 		zle_setline(he);
 		srch_hl = histline;
 		srch_cs = zlecs;
@@ -484,6 +486,7 @@ historysearchbackward(char **args)
 	    }
 	}
     }
+    unmetafy_line();
     return 1;
 }
 
@@ -524,13 +527,15 @@ historysearchforward(char **args)
     if (!(he = quietgethist(histline)))
 	return 1;
 
+    metafy_line();
     while ((he = movehistent(he, 1, hist_skip_flags))) {
 	if (isset(HISTFINDNODUPS) && he->node.flags & HIST_DUP)
 	    continue;
 	zt = GETZLETEXT(he);
 	if (zlinecmp(zt, str) < (he->histnum == curhist) &&
-	    (*args || strcmp(zt, str) != 0)) {
+	    (*args || strcmp(zt, zlemetaline) != 0)) {
 	    if (--n <= 0) {
+		unmetafy_line();
 		zle_setline(he);
 		srch_hl = histline;
 		srch_cs = zlecs;
@@ -538,6 +543,7 @@ historysearchforward(char **args)
 	    }
 	}
     }
+    unmetafy_line();
     return 1;
 }