Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Interrupts in completion, traps in _main_complete
On Tue, 09 Dec 2014 11:50:41 +0000
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> > I don't really understand what's going on with ZLE_COLORS, however. In
> > the majority of cases it just seems to be saved and restored as if it
> > were local. The only exception seems to be if the show-ambiguity style
> > is set it gets saved for use in another completion. What is it about
> > show-ambiguity that requires this? Is it so that if we redisplay a
> > listing without going through _main_complete again it appears correct?
>
> In summary: er, well, yeah.
It seems ZLS_COLORS does need to survive after the end of
_main_complete, which is a bit of a messy special case. But the patch
ensures ZLS_COLORS gets restored on an interrupt.
I don't know what, if anything, $comppostfuncs is used for apart from
_all_matches, but we could introduce a separate variable compcleanupfuncs
that goes inside the always block. Nothing in _all_matches_end looks
crucial; it does unset _all_matches_context but that's unimportant until
the next time _all_matches runs.
diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete
index 91b68fe..23b91d3 100644
--- a/Completion/Base/Core/_main_complete
+++ b/Completion/Base/Core/_main_complete
@@ -43,6 +43,8 @@ local -a precommands
typeset -U _lastdescr _comp_ignore _comp_colors
+{
+
[[ -z "$curcontext" ]] && curcontext=:::
zstyle -s ":completion:${curcontext}:" insert-tab tmp || tmp=yes
@@ -349,17 +351,20 @@ fi
( "$_comp_force_list" = ?* && nm -ge _comp_force_list ) ]] &&
compstate[list]="${compstate[list]//messages} force"
-if [[ "$compstate[old_list]" = keep ]]; then
- if [[ $_saved_colors_set = 1 ]]; then
- ZLS_COLORS="$_saved_colors"
+} always {
+ # Stuff we always do to clean up.
+ if [[ "$compstate[old_list]" = keep ]]; then
+ if [[ $_saved_colors_set = 1 ]]; then
+ ZLS_COLORS="$_saved_colors"
+ else
+ unset ZLS_COLORS
+ fi
+ elif (( $#_comp_colors )); then
+ ZLS_COLORS="${(j.:.)_comp_colors}"
else
unset ZLS_COLORS
fi
-elif (( $#_comp_colors )); then
- ZLS_COLORS="${(j.:.)_comp_colors}"
-else
- unset ZLS_COLORS
-fi
+}
# Now call the post-functions.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author