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

[PATCH/RFC] Fix compset -p/-s inconsistency and documentation



Whilst investigating workers/44272, a failure of the Y01 _tilde test led me to
discover that compset -p/-s doesn't work consistently with and without
multi-byte support:

  % _foo() { compset -p 1; _message "${(qq)IPREFIX} ${(qq)PREFIX}" }
  % compdef _foo foo

  # Without multi-byte
  % _comp_options+=( no_multibyte )
  % foo .<TAB>
  completing '' '.':

  # With multi-byte
  % _comp_options+=( multibyte )
  % foo .<TAB>
  completing '.' '':

I think this is the result of workers/41835.

Restoring the original behaviour seems simple (see patch), but i wanted to
confirm that it's the right thing, because the original behaviour actually
didn't (and the current behaviour still doesn't) match the documentation:

> If the contents of the PREFIX parameter *is longer than* number characters,
> the first number characters are removed from it and appended to the contents
> of the IPREFIX parameter.

Am i right to conclude that the documentation is wrong?

dana


diff --git a/Doc/Zsh/compwid.yo b/Doc/Zsh/compwid.yo
index 1cc94bf95..0f13b7fe0 100644
--- a/Doc/Zsh/compwid.yo
+++ b/Doc/Zsh/compwid.yo
@@ -728,8 +728,8 @@ The options are:
 
 startitem()
 item(tt(-p) var(number))(
-If the contents of the tt(PREFIX) parameter is longer than var(number)
-characters, the first var(number) characters are removed from it and
+If the value of the tt(PREFIX) parameter is at least var(number)
+characters long, the first var(number) characters are removed from it and
 appended to the contents of the tt(IPREFIX) parameter.
 )
 item(tt(-P) [ var(number) ] var(pattern))(

diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 1dc2b01c2..0f3721b05 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -962,7 +962,7 @@ do_comp_vars(int test, int na, char *sa, int nb, char *sb, int mod)
 		}
 	    } else
 #endif
-	    if ((int)strlen(test == CVT_PRENUM ? compprefix : compsuffix) >= na)
+	    if ((int)strlen(test == CVT_PRENUM ? compprefix : compsuffix) < na)
 		return 0;
 	    if (test == CVT_PRENUM)
 		ignore_prefix(na);



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