zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: fix updates to region_highlight, accounting for PREDISPLAY
@ 2023-01-10 16:55 Oliver Kiddle
  2023-01-11 13:01 ` Oliver Kiddle
  0 siblings, 1 reply; 2+ messages in thread
From: Oliver Kiddle @ 2023-01-10 16:55 UTC (permalink / raw)
  To: Zsh workers

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;
 		}
 	    }
 	}


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-11 13:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 16:55 PATCH: fix updates to region_highlight, accounting for PREDISPLAY Oliver Kiddle
2023-01-11 13:01 ` Oliver Kiddle

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).