zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Undo and narrow-to-region (was Re: PATCH: narrow-to-region (was ...))
Date: Wed, 22 Jul 2015 22:41:01 -0700	[thread overview]
Message-ID: <150722224101.ZM14105@torch.brasslantern.com> (raw)
In-Reply-To: <9927.1437383950@thecus.kiddle.eu>

On Jul 20, 11:19am, Oliver Kiddle wrote:
} Subject: Re: PATCH: narrow-to-region (was Re: This widget implementation f
}
} My main use of narrow-to-region is to retrieve history lines into the
} middle of the current line. And it is just this situation that is
} breaking it. When doing:
}   zle undo $_ntr_changeno
} it is falling foul of the first line of unapplychange which is:
}   if(ch->hist != histline) {
} and not undoing enough changes.
} 
} This is a consequence of the fix in 10328. If I comment out the two
} lines of undo() which do else break; it appears to work fine and the
} problem that 10328 targetted doesn't seem to come back. But it is hard
} to know how that was failing at the time.

So you mean that part of undo becomes

        if (unapplychange(prev))
            curchange = prev;
    } while (last_change >= (zlong)0 || (curchange->flags & CH_PREV));

??

What must be happening is that unapplychange() alters the history line,
returns zero, and then is called again with exactly the same struct,
which now succeeds on the adjusted history line.  Pre-10328, the call
to unapplychange() would fail but curchange was moved to ->prev either
way, skipping over the change that failed.

So the "else break;" looks like paranoia to prevent an infinite loop in
the event that unapplychange() fails every time.  Which could happen if
quietgethist() is a no-op?  Perhaps when a line has fallen out of the
history because of HISTSIZE?

Anyway modulo infinite-loop-prevention, it looks to me as if removing
that else-clause is the right thing to do, and similarly in redo() a
bit further along.  I'll let Oliver do the patch if we all agree.


  parent reply	other threads:[~2015-07-23  5:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-20  9:16 This widget implementation feels a bit clunky (edit-quoted-word) Mikael Magnusson
2015-06-20 17:06 ` Peter Stephenson
2015-06-21  7:09   ` Mikael Magnusson
2015-06-21 17:17     ` Peter Stephenson
2015-06-22  2:26       ` Mikael Magnusson
2015-06-22  0:18     ` PATCH: Document narrow-to-region -l and -r Mikael Magnusson
2015-06-20 17:21 ` This widget implementation feels a bit clunky (edit-quoted-word) Bart Schaefer
2015-07-18 23:42   ` PATCH: narrow-to-region (was Re: This widget implementation feels a bit clunky) Bart Schaefer
2015-07-19  3:55     ` Oliver Kiddle
2015-07-19  8:23       ` Bart Schaefer
2015-07-20  9:19         ` Oliver Kiddle
2015-07-20 16:29           ` Bart Schaefer
2015-07-23  5:41           ` Bart Schaefer [this message]
2015-07-27 15:44             ` Undo and narrow-to-region (was Re: PATCH: narrow-to-region (was ...)) Oliver Kiddle
2015-08-12 17:00               ` PATCH: Re: Undo and narrow-to-region (was ...) Oliver Kiddle
2015-08-17 21:15                 ` Daniel Hahler
2015-08-17 21:58                   ` Bart Schaefer
2015-08-18  3:43                     ` Bart Schaefer
2015-08-18  7:05                   ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=150722224101.ZM14105@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).