zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <opk@zsh.org>
To: Zsh workers <zsh-workers@zsh.org>
Subject: PATCH: fix updates to region_highlight, accounting for PREDISPLAY
Date: Tue, 10 Jan 2023 17:55:33 +0100	[thread overview]
Message-ID: <92837-1673369733.527434@Np6E.5Ah8.qv5l> (raw)

I've been paying more attention than usual to any glitches related to
terminal attributes and this fixes an old bug where dynamic updates to
region_highlight failed to allow for the PREDISPLAY part of the buffer.
You can see this bug by invoking Functions/Zle/replace-string, typing a
few characters and then using backspace - bold highlighting is lost.

I think the intention in read-from-minibuffer is that bold is only used
for the prompt. But the user-entered string starts empty and when new
characters are added to the right of a region_highlight entry, they
are included. We could solve this by excluding bold highlighting for
the final space in the read-from-minibuffer prompt but the prompt is a
parameter and may not end in a space. It would be possible to add ZRH_*
flags and some syntax for whether regions expand for new characters at
the left and right. Or perhaps just make a special case for the end of
PREDISPLAY?

I'm not certain of the code path to reach the meta half of shiftchars().

Oliver

diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 1a580a9e6..45a82dd5e 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -866,13 +866,13 @@ shiftchars(int to, int cnt)
 		    if (rhp->start_meta - sub > to + cnt)
 			rhp->start_meta -= cnt;
 		    else
-			rhp->start_meta = to;
+			rhp->start_meta = to + sub;
 		}
 		if (rhp->end_meta - sub > to) {
 		    if (rhp->end_meta - sub > to + cnt)
 			rhp->end_meta -= cnt;
 		    else
-			rhp->end_meta = to;
+			rhp->end_meta = to + sub;
 		}
 	    }
 	}
@@ -896,13 +896,13 @@ shiftchars(int to, int cnt)
 		    if (rhp->start - sub > to + cnt)
 			rhp->start -= cnt;
 		    else
-			rhp->start = to;
+			rhp->start = to + sub;
 		}
 		if (rhp->end - sub > to) {
 		    if (rhp->end - sub > to + cnt)
 			rhp->end -= cnt;
 		    else
-			rhp->end = to;
+			rhp->end = to + sub;
 		}
 	    }
 	}


             reply	other threads:[~2023-01-10 16:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 16:55 Oliver Kiddle [this message]
2023-01-11 13:01 ` Oliver Kiddle

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=92837-1673369733.527434@Np6E.5Ah8.qv5l \
    --to=opk@zsh.org \
    --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).