* PATCH: fix use of vi-fetch-history use with a range
@ 2024-11-15 16:53 Oliver Kiddle
0 siblings, 0 replies; only message in thread
From: Oliver Kiddle @ 2024-11-15 16:53 UTC (permalink / raw)
To: Zsh workers
In my own setup, I have G bound to a custom widget but I happened to be
using an unconfigured zsh and after pressing dG from vi command mode,
weird things happened with the cursor positioned on the line before the
prompt.
When later checking the code, many history widgets guard against use
in a vi range and return 1. That's absent from vi-fetch-history and,
when invoked in a vi range from an address sanitizer enabled build it
generates errors. This patch fixes a couple of other widgets - just
those where I could reproduce problems but there could well be others
especially if taking account of widgets that are unlikely to be bound in
vi mode.
For vi-fetch-history, moving to the end of the buffer is rather more
useful than bailing out so that is what this does.
Oliver
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index 0fdad70d9..53c722621 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -1758,7 +1758,8 @@ acceptandinfernexthistory(char **args)
{
Histent he;
- if (!(he = infernexthist(hist_ring, args)))
+ if (virangeflag || !(zlereadflags & ZLRF_HISTORY) ||
+ !(he = infernexthist(hist_ring, args)))
return 1;
zpushnode(bufstack, ztrdup(he->node.nam));
done = 1;
@@ -1770,8 +1771,11 @@ acceptandinfernexthistory(char **args)
int
infernexthistory(char **args)
{
- Histent he = quietgethist(histline);
+ Histent he;
+ if (virangeflag || !(zlereadflags & ZLRF_HISTORY))
+ return 1;
+ he = quietgethist(histline);
if (!he || !(he = infernexthist(he, args)))
return 1;
zle_setline(he);
@@ -1784,12 +1788,14 @@ vifetchhistory(UNUSED(char **args))
{
if (zmult < 0)
return 1;
- if (histline == curhist) {
+ if (histline == curhist || virangeflag || !(zlereadflags & ZLRF_HISTORY)) {
if (!(zmod.flags & MOD_MULT)) {
zlecs = zlell;
zlecs = findbol();
return 0;
}
+ if (virangeflag || !(zlereadflags & ZLRF_HISTORY))
+ return 1;
}
if (!zle_goto_hist((zmod.flags & MOD_MULT) ? zmult : curhist, 0, 0) &&
isset(HISTBEEP)) {
@@ -1933,6 +1939,9 @@ getvisrchstr(void)
int
vihistorysearchforward(char **args)
{
+ if (virangeflag || !(zlereadflags & ZLRF_HISTORY))
+ return 1;
+
if (*args) {
int ose = visrchsense, ret;
char *ost = visrchstr;
@@ -1954,6 +1963,9 @@ vihistorysearchforward(char **args)
int
vihistorysearchbackward(char **args)
{
+ if (virangeflag || !(zlereadflags & ZLRF_HISTORY))
+ return 1;
+
if (*args) {
int ose = visrchsense, ret;
char *ost = visrchstr;
@@ -1979,8 +1991,9 @@ virepeatsearch(UNUSED(char **args))
int n = zmult;
char *zt;
- if (!visrchstr)
+ if (!visrchstr || virangeflag || !(zlereadflags & ZLRF_HISTORY))
return 1;
+
if (zmult < 0) {
n = -n;
visrchsense = -visrchsense;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-11-15 16:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-15 16:53 PATCH: fix use of vi-fetch-history use with a range 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).