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

Re: bashcompinit incorrectly calculates COMP_LINE (proposed fix included)



On Fri, 17 Nov 2017 20:19:25 +1100
Evan Underscore <evanunderscore@xxxxxxxxx> 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 )



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