zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH/RFC] Fix compset -p/-s inconsistency and documentation
@ 2019-05-06 23:11 dana
  0 siblings, 0 replies; only message in thread
From: dana @ 2019-05-06 23:11 UTC (permalink / raw)
  To: Zsh hackers list

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);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-06 23:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-06 23:11 [PATCH/RFC] Fix compset -p/-s inconsistency and documentation dana

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).