Re: PATCH: Fix crash with bracketed-paste-magic and undo
Lukáš Zaoral <[email protected]> Tue, 21 Jul 2026 15:23:20 +0200
| Newsgroups | gmane.comp.shells.zsh.devel |
|---|---|
| Message-ID | <[email protected]> |
Thanks a lot for the patch, Mikael! I=E2=80=99ve tested it successfully wi= th latest master on both x86_64 Fedora 44 and aarch64 Fedora Rawhide. Regards, Lukas > On 17. 7. 2026, at 23:57, Mikael Magnusson <[email protected]> wrote: >=20 > In particular, fc -P/-p didn't interact well with undo. Make sure we > store/restore histline across those calls. >=20 > --- >=20 > I think this should fix it, and hopefully not break anything else. >=20 > BTW, if you don't need any of the crazy features in bracketed-paste-magic= , I would > recommend using bracketed-paste-url-magic instead. >=20 > I also tried some old binaries I had lying around, the crash has happened= at least > since 5.3. >=20 > Src/Zle/zle_main.c | 8 ++++++++ > Src/hist.c | 7 ++++++- > Src/zsh.h | 1 + > 3 files changed, 15 insertions(+), 1 deletion(-) >=20 > diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c > index ea88a42475..cb226932b4 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; > } >=20 > + case ZLE_CMD_GET_HIST_LINE: > + { > + zlong *p =3D va_arg(ap, zlong *); > + *p =3D histline; > + > + break; > + } > + > case ZLE_CMD_PREEXEC: > mark_output(1); > break; > diff --git a/Src/hist.c b/Src/hist.c > index de21a4ff64..c353601bf0 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 l= evel) > h->histsiz =3D histsiz; > h->savehistsiz =3D savehistsiz; > h->locallevel =3D level; > + if (zleactive) > + zleentry(ZLE_CMD_GET_HIST_LINE, &h->histline); > + else > + h->histline =3D 0; >=20 > memset(&lasthist, 0, sizeof lasthist); > if (hf) { > @@ -3925,7 +3930,7 @@ pophiststack(void) > hist_ring =3D h->hist_ring; > curhist =3D h->curhist; > if (zleactive) > - zleentry(ZLE_CMD_SET_HIST_LINE, curhist); > + zleentry(ZLE_CMD_SET_HIST_LINE, h->histline); > histlinect =3D h->histlinect; > histsiz =3D h->histsiz; > savehistsiz =3D h->savehistsiz; > diff --git a/Src/zsh.h b/Src/zsh.h > index c9dc413a21..29dbb5e692 100644 > --- a/Src/zsh.h > +++ b/Src/zsh.h > @@ -3239,6 +3239,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 > --=20 > 2.38.1 >=20