Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: fix updates to region_highlight, accounting for PREDISPLAY
- X-seq: zsh-workers 51292
- From: Oliver Kiddle <opk@xxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: fix updates to region_highlight, accounting for PREDISPLAY
- Date: Tue, 10 Jan 2023 17:55:33 +0100
- Archived-at: <https://zsh.org/workers/51292>
- List-id: <zsh-workers.zsh.org>
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;
}
}
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author