* bashcompinit incorrectly calculates COMP_LINE (proposed fix included)
@ 2017-11-17 9:19 Evan Underscore
2017-11-19 19:49 ` Peter Stephenson
0 siblings, 1 reply; 3+ messages in thread
From: Evan Underscore @ 2017-11-17 9:19 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 962 bytes --]
Hi all,
A user discovered a bug in bashcompinit that causes COMP_LINE to be
incorrectly calculated. A summary of the incorrect behaviour is here:
https://github.com/kislyuk/argcomplete/issues/228#issuecomment-327696251
(Note some of the surrounding discussion is incorrect - this bug is
unrelated to unicode.) The table at the bottom of this comment summarises
how bashcompinit differs in its calculation of COMP_POINT.
The change that caused the bug appears to have been introduced here:
https://github.com/zsh-users/zsh/commit/23907bb840c80eef99eabba17e086e44c9b2d3fc#diff-b8d49b00032bcbfcdc709649f5d68505R11
Reverting this line (i.e. using CURRENT-1 instead of CURRENT, as it was
before this commit) fixes the bug for me, causing zsh to report 18 and 19
for the two test lines respectively, matching Bash.
I am not a subscriber; please send responses to this email address. I wish
to note the resolution of this on the argcomplete ticket.
Thanks,
Evan.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: bashcompinit incorrectly calculates COMP_LINE (proposed fix included)
2017-11-17 9:19 bashcompinit incorrectly calculates COMP_LINE (proposed fix included) Evan Underscore
@ 2017-11-19 19:49 ` Peter Stephenson
2017-11-19 22:55 ` Evan Underscore
0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2017-11-19 19:49 UTC (permalink / raw)
To: Evan Underscore, zsh-workers
On Fri, 17 Nov 2017 20:19:25 +1100
Evan Underscore <evanunderscore@gmail.com> wrote:
> Reverting this line (i.e. using CURRENT-1 instead of CURRENT, as it was
> before this commit) fixes the bug for me, causing zsh to report 18 and 19
> for the two test lines respectively, matching Bash.
So I think so suggesting the following patch gives the correct behaviour
under all circumstances you aware of?
pws
diff --git a/Completion/bashcompinit b/Completion/bashcompinit
index 902fa88..02290a1 100644
--- a/Completion/bashcompinit
+++ b/Completion/bashcompinit
@@ -8,7 +8,7 @@ _bash_complete() {
local -x COMP_LINE="$words"
local -A savejobstates savejobtexts
- (( COMP_POINT = 1 + ${#${(j. .)words[1,CURRENT]}} + $#QIPREFIX + $#IPREFIX + $#PREFIX ))
+ (( COMP_POINT = 1 + ${#${(j. .)words[1,CURRENT-1]}} + $#QIPREFIX + $#IPREFIX + $#PREFIX ))
(( COMP_CWORD = CURRENT - 1))
COMP_WORDS=( $words )
BASH_VERSINFO=( 2 05b 0 1 release )
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: bashcompinit incorrectly calculates COMP_LINE (proposed fix included)
2017-11-19 19:49 ` Peter Stephenson
@ 2017-11-19 22:55 ` Evan Underscore
0 siblings, 0 replies; 3+ messages in thread
From: Evan Underscore @ 2017-11-19 22:55 UTC (permalink / raw)
To: Peter Stephenson; +Cc: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 1378 bytes --]
Yes, that patch works for me for the following test cases:
./demo.py new test[tab] (COMP_POINT=18)
./demo.py new test [tab] (COMP_POINT=19)
./demo.py new 你好嘚瑟[tab] (COMP_POINT=18)
./demo.py new 你好嘚瑟 [tab] (COMP_POINT=19)
Thanks.
On Mon, Nov 20, 2017 at 6:49 AM, Peter Stephenson <
p.w.stephenson@ntlworld.com> wrote:
> On Fri, 17 Nov 2017 20:19:25 +1100
> Evan Underscore <evanunderscore@gmail.com> wrote:
> > Reverting this line (i.e. using CURRENT-1 instead of CURRENT, as it was
> > before this commit) fixes the bug for me, causing zsh to report 18 and 19
> > for the two test lines respectively, matching Bash.
>
> So I think so suggesting the following patch gives the correct behaviour
> under all circumstances you aware of?
>
> pws
>
>
> diff --git a/Completion/bashcompinit b/Completion/bashcompinit
> index 902fa88..02290a1 100644
> --- a/Completion/bashcompinit
> +++ b/Completion/bashcompinit
> @@ -8,7 +8,7 @@ _bash_complete() {
> local -x COMP_LINE="$words"
> local -A savejobstates savejobtexts
>
> - (( COMP_POINT = 1 + ${#${(j. .)words[1,CURRENT]}} + $#QIPREFIX +
> $#IPREFIX + $#PREFIX ))
> + (( COMP_POINT = 1 + ${#${(j. .)words[1,CURRENT-1]}} + $#QIPREFIX +
> $#IPREFIX + $#PREFIX ))
> (( COMP_CWORD = CURRENT - 1))
> COMP_WORDS=( $words )
> BASH_VERSINFO=( 2 05b 0 1 release )
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-19 22:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-17 9:19 bashcompinit incorrectly calculates COMP_LINE (proposed fix included) Evan Underscore
2017-11-19 19:49 ` Peter Stephenson
2017-11-19 22:55 ` Evan Underscore
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).