From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3388 invoked by alias); 21 Jul 2018 11:15:16 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43197 Received: (qmail 6153 invoked by uid 1010); 21 Jul 2018 11:15:15 -0000 X-Qmail-Scanner-Diagnostics: from g.primenet.com.au by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:1(203.24.36.10):. Processed in 0.229394 secs); 21 Jul 2018 11:15:15 -0000 Date: Sat, 21 Jul 2018 21:15:14 +1000 From: Geoff Wing To: zsh-workers@zsh.org Subject: Fwd: Perplexing `COMP_POINT` value on bashcompinit tab completion Message-ID: <20180721111514.GA6123@primenet.com.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="EVF5PPMfhYS0aIcm" Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) --EVF5PPMfhYS0aIcm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline HTML message --EVF5PPMfhYS0aIcm Content-Type: message/rfc822 Content-Disposition: inline Return-Path: Delivered-To: gcw-moderator@sparkles.primenet.com.au Received: (qmail 3242 invoked from network); 21 Jul 2018 09:31:11 -0000 Received: from f.primenet.com.au (HELO primenet.com.au) (203.43.15.2) by g.primenet.com.au with ESMTPS (ECDHE-RSA-AES256-GCM-SHA384 encrypted); 21 Jul 2018 09:31:11 -0000 Received: (qmail 9021 invoked by uid 100); 21 Jul 2018 09:31:11 -0000 Delivered-To: gcw-moderator@primenet.com.au Received: (qmail 1997 invoked by alias); 21 Jul 2018 09:31:11 -0000 Delivered-To: zsh_alias-zsh-workers@zsh.org Received: (qmail 27913 invoked by uid 1010); 21 Jul 2018 09:31:11 -0000 X-Qmail-Scanner-Diagnostics: from mail-ed1-f50.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.208.50):SA:0(-0.9/5.0):. Processed in 1.086332 secs); 21 Jul 2018 09:31:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE,MIME_HTML_ONLY, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: saverio.pub2@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received: from mail-ed1-f50.google.com (209.85.208.50) by ns1.primenet.com.au with ESMTPS (ECDHE-RSA-AES128-GCM-SHA256 encrypted); 21 Jul 2018 09:31:09 -0000 Received: by mail-ed1-f50.google.com with SMTP id x5-v6so11614041edr.0 for ; Sat, 21 Jul 2018 02:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=kgjsgwhE/9VHnUAZ0Bdb8QSKZTkmr2NOwLxUyWGdplc=; b=qwmhQKrYiuXeSBRK53cp8UKkCisOT6nuF/9a4w7aoyPhM66X0HlG3vN8c3+2P2FM0I iEjYLblQLY6M6uF/KvYMRJt8/db8B8AeivDD7ZpUVQyr+sxvSeq/T+CsWwYlo3N3CPsc FJAe2vLpKWFPm1GcXiZGSAzDATfEW5kxCtAKo35qHA0WwolIAoZUIH7tv4cq1qAPtgpL ygAUAMBEVrhPe15XinOh/i0dDqt42/iNza4W9Uz2QdznVix/gO72wv7NDzYo5JW2/tMj iIi4eajRIGY9Zw5vCUOxOwl50ry04aYpSyX+F9RSDijGRMH6IMG9FX36Tyw6kvSKvcNh ZflA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=kgjsgwhE/9VHnUAZ0Bdb8QSKZTkmr2NOwLxUyWGdplc=; b=J/BgFnQZZQv2hHShuO0pKS34UHbBk0S8ZsjtxhgRLhWbaGHzbmW6G/QtaoIwX7c9le Knc+vu/MSS3EVGvuzIxRJ0r36Q6U094eR8k18O4kRT2zTziijZjdTBD9Cf3q0U4IQdLu bDTeBQTuDxTVbWPZjEwM75MFO6dvD/SoqSB6pWJtejvXV1KG26hFKUkQPDYX75NcSi7R F+XZzyU42BOezYiXOm+5JRU47cr6Z4Btw+bcqBdCZBiTwYF69L/ZgFJn+4fv03mUEcJh +CDMivZCvCYT0yuKZ0jtWGF2IVEWfHoJy/kVwFh3O1EbXgp14fe0XqF5Q/Xkg9gYcsVR mGSg== X-Gm-Message-State: AOUpUlFb53qMSHbo6UnxQgr9QWVbdSGKDFomDbUxJCekjZ51nU9nyN4O 9Dbppmksmj3PD/7cV5UosWwcbI0K X-Google-Smtp-Source: AAOMgpeRhL8ay7rLC0UlCnrU8hV6Xfb3fm6PDMGZVGQ2Q6chMAw/6dc4eTZQDUu8ZZo4cTJiw/ylWQ== X-Received: by 2002:a50:afc4:: with SMTP id h62-v6mr5890425edd.251.1532165464581; Sat, 21 Jul 2018 02:31:04 -0700 (PDT) Return-Path: Received: from [192.168.178.20] (mue-88-130-49-195.dsl.tropolys.de. [88.130.49.195]) by smtp.gmail.com with ESMTPSA id x40-v6sm2969695ede.23.2018.07.21.02.31.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Jul 2018 02:31:03 -0700 (PDT) To: zsh-workers@zsh.org From: "Saverio M." Subject: Perplexing `COMP_POINT` value on bashcompinit tab completion Message-ID: <25ee6db0-9ef4-aa7c-e1eb-a7adfd590451@gmail.com> Date: Sat, 21 Jul 2018 11:31:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: text/html; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Hello!

I use the OMZ/`bashcompinit` combination in order to write my tab completion scripts.

The tab completion itself works, however, I'm writing more complex scripts, and I find the `COMP_POINT` value perplexing, since it doesn't match the intuitive value (the position of the cursor in the string, which is what Bash returns).

Let's suppose you have a script named `/home/oooh_my_tab/scr`, whose autocompletion is defined via `complete -C "/path/to/myscript_completion" -o default scr`.

When typing:

```sh
$ scr <tab>
```

Bash sends to the completion script the env vars `COMP_LINE=scr ` and `COMP_POINT=4`. The number `4` is, intuitively, the position of the cursor (and the size of the `COMP_LINE` string).

Zsh sends `COMP_LINE=/home/oooh_my_tab/scr `, which is different while correct nonetheless, but sends `COMP_POINT=23`, which is perplexing, since the position of the cursor is `22`.

When typing:

```sh
$ scr a<tab>
```

Bash sends `COMP_LINE=scr a` and `COMP_POINT=5`, which, again, has intuitive values.

Zsh sends `COMP_LINE=/home/oooh_my_tab/scr a`, and the now more perplexing `COMP_POINT=25`, which adds an unexpected extra unit to what was, in the previous example, an already apparently off-by-one value.

Is this a bug? Am I missing something? With such behavior, `COMP_POINT` breaks compatibility with Bash tab completion scripts.

Thanks,
Saverio
--EVF5PPMfhYS0aIcm--