From 35c87f0b3bc0ce5a22a6bf3b0f2b2a14a3993cea Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Mon, 6 Sep 2021 13:33:40 -0700 Subject: [PATCH] unposted (cf. 49202 and 49217): insertlastword ignores blank/missing history entries when repeating --- ChangeLog | 3 +++ Src/Zle/zle_hist.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 31beb268e..fdaea5678 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2021-09-06 Bart Schaefer + * unposted (cf. 49202 and 49217): Src/Zle/zle_hist.c: insertlastword + ignores blank/missing history entries when repeating + * 49196: Src/Modules/db_gdbm.c: gdbm keys not present in the database appear unset in tied hashes diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c index 581ca4979..cfaa70dae 100644 --- a/Src/Zle/zle_hist.c +++ b/Src/Zle/zle_hist.c @@ -683,8 +683,13 @@ insertlastword(char **args) } nwords = countlinknodes(l); } else { - /* Some stored line. */ - if (!(he = quietgethist(evhist)) || !he->nwords) { + /* Some stored line. By default, search for a non-empty line. */ + while ((he = quietgethist(evhist)) && histstep == -1 && !*args) { + if (he->nwords) + break; + evhist = addhistnum(evhist, histstep, HIST_FOREIGN); + } + if (!he || !he->nwords) { unmetafy_line(); return 1; }