Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: (partially) Re: %<< and %{%}



On Feb 29,  5:32pm, Bart Schaefer wrote:
} Subject: Re: %<< and %{%}
}
} On Mar 1, 12:26am, Tanaka Akira wrote:
} } Subject: %<< and %{%}
} }
} } I heard that the combination of %<< and %{%} in prompt doesn't work well.
} } 
} } Hm.  The string in %{..%} is affected to truncation.  It is wrong.

Had a quick look at this ... unfortunately, the way prompt truncation
is now calculated, the knowledge of what strings were contained inside
%{...%} has been lost by the time we start computing the truncation.
That means that we might even truncate into the middle of a %{...%}.

Prior to 4601 (and in the 3.0 series), prompt truncation applied to
exactly one following %-escape, which made it very difficult to specify
the total length of the prompt.  4601 introduced the idea of truncating
the entire remainder of the prompt, unless truncation were explicitly
limited by either enclosing it in %(...) or by an empty truncation, as
I suggested here:

} PS1=$'[%20<..<%/%<<]%{\e[33m%}'

Unfortunately this has the unwanted side-effect that the prompt is fully
generated before its size is counted for truncation -- and hence the
trouble with %{...%}.

Fixing this is going to require another rethinking of putpromptchar().

} There does seem to be a bug with handling of turncations inside the %()
} conditional construct; if the truncation is in the "true" branch, then
} the false branch and the trailing `)' are left as part of the prompt.

That, however, is easily fixed.

Index: Src/prompt.c
===================================================================
@@ -815,9 +815,9 @@
 	     */
 	    if (!putpromptchar(doprint, endchar))
 		return 0;
-	    /* Now we have to trick it into matching endchar again */
-	    fm--;
 	}
+	/* Now we have to trick it into matching endchar again */
+	fm--;
     } else {
 	if (*fm != ']')
 	    fm++;

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author