zsh-workers
 help / Atom feed
* [PATCH/RFC] Fix compset -p/-s inconsistency and documentation
@ 2019-05-06 23:11 dana
  0 siblings, 0 replies; 1+ messages 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] 1+ messages in thread

only message in thread, back to index

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

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/ public-inbox