about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2013-08-08 19:48:11 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2013-08-08 19:48:11 +0100
commit0b185e3dcd7348045787b972a80d62da4ca0c79f (patch)
treed6a02419c2b0b8307897c00357b21efaae2e3d62 /Src
parent180c4c049c60c963378da8f9582937eb1682870e (diff)
downloadzsh-0b185e3dcd7348045787b972a80d62da4ca0c79f.tar.gz
zsh-0b185e3dcd7348045787b972a80d62da4ca0c79f.tar.xz
zsh-0b185e3dcd7348045787b972a80d62da4ca0c79f.zip
users/17908: Keep history line in sync between ZLE and shell.
Update ZLE version if history is read, pushed or popped with ZLE active
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/zle_main.c7
-rw-r--r--Src/hist.c10
-rw-r--r--Src/zsh.h3
3 files changed, 19 insertions, 1 deletions
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index a1d54dd2b..756ff111a 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1934,6 +1934,13 @@ zle_main_entry(int cmd, va_list ap)
 	break;
     }
 
+    case ZLE_CMD_SET_HIST_LINE:
+    {
+	histline = va_arg(ap, zlong);
+
+	break;
+    }
+
     default:
 #ifdef DEBUG
 	    dputs("Bad command %d in zle_main_entry", cmd);
diff --git a/Src/hist.c b/Src/hist.c
index 5e962e92f..f78c97d8f 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -76,6 +76,9 @@ mod_export int excs, exlast;
  * and a temporary history entry is inserted while the user is editing.
  * If the resulting line was not added to the list, a flag is set so
  * that curhist will be decremented in hbegin().
+ *
+ * Note curhist is passed to zle on variable length argument list:
+ * type must match that retrieved in zle_main_entry.
  */
  
 /**/
@@ -2414,6 +2417,9 @@ readhistfile(char *fn, int err, int readflags)
 	zerr("can't read history file %s", fn);
 
     unlockhistfile(fn);
+
+    if (zleactive)
+	zleentry(ZLE_CMD_SET_HIST_LINE, curhist);
 }
 
 #ifdef HAVE_FCNTL_H
@@ -3339,6 +3345,8 @@ pushhiststack(char *hf, zlong hs, zlong shs, int level)
     }
     hist_ring = NULL;
     curhist = histlinect = 0;
+    if (zleactive)
+	zleentry(ZLE_CMD_SET_HIST_LINE, curhist);
     histsiz = hs;
     savehistsiz = shs;
     inithist(); /* sets histtab */
@@ -3378,6 +3386,8 @@ pophiststack(void)
     histtab = h->histtab;
     hist_ring = h->hist_ring;
     curhist = h->curhist;
+    if (zleactive)
+	zleentry(ZLE_CMD_SET_HIST_LINE, curhist);
     histlinect = h->histlinect;
     histsiz = h->histsiz;
     savehistsiz = h->savehistsiz;
diff --git a/Src/zsh.h b/Src/zsh.h
index d7b130c72..e6f0f65db 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -2756,7 +2756,8 @@ enum {
     ZLE_CMD_RESET_PROMPT,
     ZLE_CMD_REFRESH,
     ZLE_CMD_SET_KEYMAP,
-    ZLE_CMD_GET_KEY
+    ZLE_CMD_GET_KEY,
+    ZLE_CMD_SET_HIST_LINE
 };
 
 /***************************************/