From: Sav Erio <saverio.pub2@gmail.com>
To: zsh-workers@zsh.org
Subject: Perplexing `COMP_POINT` value on bashcompinit tab completion (plaintext)
Date: Sun, 22 Jul 2018 10:05:08 +0200 [thread overview]
Message-ID: <CAKtPU9hPtLXdT_5J9EKf329FnPJ=wL4VsTWMEh6Lj9h8QBkgRw@mail.gmail.com> (raw)
(I've previously sent this email from my email client, which sends in
HTML; this has apparently didn't work well with the mailing list
software, so I'm resending it from the Gmail web app, which should be
plaintext).
=====
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
next reply other threads:[~2018-07-22 8:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-22 8:05 Sav Erio [this message]
2018-07-23 15:39 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKtPU9hPtLXdT_5J9EKf329FnPJ=wL4VsTWMEh6Lj9h8QBkgRw@mail.gmail.com' \
--to=saverio.pub2@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).