summaryrefslogtreecommitdiffstats
path: root/Src
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2026-07-17 22:53:21 +0200
committerMikael Magnusson <mikachu@gmail.com>2026-07-21 16:20:48 +0200
commit7708d466dfab8dd29f9ae5de12c74af37bf99a4d (patch)
tree15bcd55631a90eebee679d08f5cc7fb8838b8da2 /Src
parentunposted: ChangeLog for previous four commits (diff)
downloadzsh-7708d466dfab8dd29f9ae5de12c74af37bf99a4d.tar
zsh-7708d466dfab8dd29f9ae5de12c74af37bf99a4d.tar.gz
zsh-7708d466dfab8dd29f9ae5de12c74af37bf99a4d.tar.bz2
zsh-7708d466dfab8dd29f9ae5de12c74af37bf99a4d.tar.lz
zsh-7708d466dfab8dd29f9ae5de12c74af37bf99a4d.tar.xz
zsh-7708d466dfab8dd29f9ae5de12c74af37bf99a4d.tar.zst
zsh-7708d466dfab8dd29f9ae5de12c74af37bf99a4d.zip
54985: fix crash with bracketed-paste-magic and undo
In particular, fc -P/-p didn't interact well with undo. Make sure we store/restore histline across those calls.
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/zle_main.c8
-rw-r--r--Src/hist.c7
-rw-r--r--Src/zsh.h1
3 files changed, 15 insertions, 1 deletions
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 0e581365f..921ebb9ec 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -2185,6 +2185,14 @@ zle_main_entry(int cmd, va_list ap)
break;
}
+ case ZLE_CMD_GET_HIST_LINE:
+ {
+ zlong *p = va_arg(ap, zlong *);
+ *p = histline;
+
+ break;
+ }
+
case ZLE_CMD_PREEXEC:
mark_output(1);
break;
diff --git a/Src/hist.c b/Src/hist.c
index de21a4ff6..c353601bf 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -231,6 +231,7 @@ static struct histsave {
HashTable histtab;
Histent hist_ring;
zlong curhist;
+ zlong histline;
zlong histlinect;
zlong histsiz;
zlong savehistsiz;
@@ -3873,6 +3874,10 @@ pushhiststack(char *hf, zlong hs, zlong shs, int level)
h->histsiz = histsiz;
h->savehistsiz = savehistsiz;
h->locallevel = level;
+ if (zleactive)
+ zleentry(ZLE_CMD_GET_HIST_LINE, &h->histline);
+ else
+ h->histline = 0;
memset(&lasthist, 0, sizeof lasthist);
if (hf) {
@@ -3925,7 +3930,7 @@ pophiststack(void)
hist_ring = h->hist_ring;
curhist = h->curhist;
if (zleactive)
- zleentry(ZLE_CMD_SET_HIST_LINE, curhist);
+ zleentry(ZLE_CMD_SET_HIST_LINE, h->histline);
histlinect = h->histlinect;
histsiz = h->histsiz;
savehistsiz = h->savehistsiz;
diff --git a/Src/zsh.h b/Src/zsh.h
index 1f1ecc3e6..2054c07b6 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -3237,6 +3237,7 @@ enum {
ZLE_CMD_SET_KEYMAP,
ZLE_CMD_GET_KEY,
ZLE_CMD_SET_HIST_LINE,
+ ZLE_CMD_GET_HIST_LINE,
ZLE_CMD_PREEXEC,
ZLE_CMD_POSTEXEC,
ZLE_CMD_CHPWD