summary refs log tree commit diff
path: root/Src/Zle
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/zle_params.c13
-rw-r--r--Src/Zle/zle_tricky.c16
2 files changed, 20 insertions, 9 deletions
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index f384753e2..2883c0fbd 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -334,8 +334,19 @@ get_rbuffer(UNUSED(Param pm))
 static char *
 get_prebuffer(UNUSED(Param pm))
 {
-    if (chline)
+    /*
+     * Use the editing current history line, not necessarily the
+     * history line that's currently in the history mechanism
+     * since our line may have been stacked.
+     */
+    if (zle_chline) {
+	/* zle_chline was NULL terminated when pushed onto the stack */
+	return dupstring(zle_chline);
+    }
+    if (chline) {
+	/* hptr is valid */
 	return dupstrpfx(chline, hptr - chline);
+    }
     return dupstring("");
 }
 
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index dce7fb700..3e2a35171 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -632,16 +632,16 @@ docomplete(int lst)
     origline = dupstring(zlemetaline);
     origcs = zlemetacs;
     origll = zlemetall;
-    if (!isfirstln && chline != NULL) {
-	/* If we are completing in a multi-line buffer (which was not  *
-	 * taken from the history), we have to prepend the stuff saved *
-	 * in chline to the contents of line.                          */
-
+    if (!isfirstln && (chline != NULL || zle_chline != NULL)) {
 	ol = dupstring(zlemetaline);
-	/* Make sure that chline is zero-terminated. */
-	*hptr = '\0';
+	/*
+	 * Make sure that chline is zero-terminated.
+	 * zle_chline always is and hptr doesn't point into it anyway.
+	 */
+	if (!zle_chline)
+	    *hptr = '\0';
 	zlemetacs = 0;
-	inststr(chline);
+	inststr(zle_chline ? zle_chline : chline);
 	chl = zlemetacs;
 	zlemetacs += ocs;
     } else