zsh-workers
 help / color / mirror / code / Atom feed
* Minor history bugfix
@ 2001-05-10 17:25 Wayne Davison
  0 siblings, 0 replies; only message in thread
From: Wayne Davison @ 2001-05-10 17:25 UTC (permalink / raw)
  To: Zsh Workers

While I was playing around with the history code, I found an obscure bug
in the current codebase.  If you have SHARE_HISTORY on but HIST_NO_STORE
off, plus you have local-history mode set (so that you don't see foreign
commands when moving up and down in the history), and you type a second
"history" command in a row that just happens to slurp in some foreign
history in between the two, the displayed history is not quite right.

The fix is much simpler than the problem description above.  The old
code was trying to get fancy when it merged the current command with the
previously-typed one.  This patch makes it do the simple thing that will
always work right.

..wayne..

---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: Src/hist.c
@@ -1067,8 +1067,6 @@
 	Histent he;
 	int keepflags;

-	for (he = hist_ring; he && he->flags & hist_skip_flags;
-	     he = up_histent(he)) ;
 #ifdef DEBUG
 	/* debugging only */
 	if (chwordpos%2) {
@@ -1083,13 +1081,14 @@
 	    if (isset(HISTREDUCEBLANKS))
 		histreduceblanks();
 	}
-	if ((isset(HISTIGNOREDUPS) || isset(HISTIGNOREALLDUPS)) && he
-	 && histstrcmp(chline, he->text) == 0) {
+	if ((isset(HISTIGNOREDUPS) || isset(HISTIGNOREALLDUPS)) && hist_ring
+	 && histstrcmp(chline, hist_ring->text) == 0) {
 	    /* This history entry compares the same as the previous.
 	     * In case minor changes were made, we overwrite the
 	     * previous one with the current one.  This also gets the
 	     * timestamp right.  Perhaps, preserve the HIST_OLD flag.
 	     */
+	    he = hist_ring;
 	    keepflags = he->flags & HIST_OLD; /* Avoid re-saving */
 	    freehistdata(he, 0);
 	    curline.histnum = curhist;
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-05-10 17:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-10 17:25 Minor history bugfix Wayne Davison

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).