zsh-workers
 help / color / mirror / code / Atom feed
* Perplexing `COMP_POINT` value on bashcompinit tab completion (plaintext)
@ 2018-07-22  8:05 Sav Erio
  2018-07-23 15:39 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Sav Erio @ 2018-07-22  8:05 UTC (permalink / raw)
  To: zsh-workers

(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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Perplexing `COMP_POINT` value on bashcompinit tab completion (plaintext)
  2018-07-22  8:05 Perplexing `COMP_POINT` value on bashcompinit tab completion (plaintext) Sav Erio
@ 2018-07-23 15:39 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2018-07-23 15:39 UTC (permalink / raw)
  To: zsh-workers; +Cc: Sav Erio

Just to put a response on this thread for the archives (details
elsewhere, search COMP_POINT near this date):

This is indeed a bug, fixed in zsh 5.4.2 but present in the stock zsh
for Ubuntu 16.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-23 15:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-22  8:05 Perplexing `COMP_POINT` value on bashcompinit tab completion (plaintext) Sav Erio
2018-07-23 15:39 ` Bart Schaefer

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).