zsh-workers
 help / color / mirror / code / Atom feed
* Why is an 'x' appended in _prefix completer?
@ 2023-03-08 10:32 Marlon Richert
  2023-03-08 12:48 ` Mikael Magnusson
  0 siblings, 1 reply; 6+ messages in thread
From: Marlon Richert @ 2023-03-08 10:32 UTC (permalink / raw)
  To: Zsh hackers list

In _prefix, line 53, why is an 'x' appended to the completion? Looks
like a (21-year-old) typo to me.


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: Why is an 'x' appended in _prefix completer?
@ 2023-04-11  9:49 Marlon Richert
  0 siblings, 0 replies; 6+ messages in thread
From: Marlon Richert @ 2023-04-11  9:49 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Mikael Magnusson, Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 1617 bytes --]

> On 8 Mar 2023, at 19:48, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Wed, Mar 8, 2023 at 4:49 AM Mikael Magnusson <mikachu@gmail.com>
wrote:
>>
>> See the comment above addx() in zle_tricky.c and get_comp_string() (i
>> don't actually recommend looking at this code).
>
> I always wondered why Sven chose to use "x" instead of, say, something
> out-of-band / non-printable.  I guess with metafication etc. maybe
> there wasn't any such thing.
>
> Anyway, as I recall it, the point of the extra character is to help
> completion distinguish the position of word breaks when completing
> somewhere other than at end of line.

I brought this up, because it has bugs.

Here are two test cases, each of which uses the following setup:

% mkdir foo bar baz
% setopt completeinword
% zstyle '*' completer _complete _prefix
% autoload compinit
% compinit
% bindkey '\t' tst
% zle -C tst complete-word tst


*Case 1: Literal x is inserted into command line*

% tst() {
  _main_complete
  compstate[insert]=1
}
% file fbar
       ^ Position the cursor over here, then press Tab

This results in:
% file fooxbar


*Case 2: Wrong character is set as autoremovable suffix*

% test() {
  _main_complete
  compstate[insert]=1
  compstate[to_end]=
}
% file bfoo
       ^ Position the cursor over here, then press Tab

This results in the following, which at first glance looks correct:
% file bar/foo

However, if you then press Space, this results in:
% file ba /foo

If you use region_highlight for the suffix, the r is highlighted as
autoremovable, too.

[-- Attachment #2: Type: text/html, Size: 5056 bytes --]

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

end of thread, other threads:[~2023-04-11  9:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 10:32 Why is an 'x' appended in _prefix completer? Marlon Richert
2023-03-08 12:48 ` Mikael Magnusson
2023-03-08 17:48   ` Bart Schaefer
2023-03-09  9:21     ` Peter Stephenson
2023-03-09 15:29       ` Bart Schaefer
2023-04-11  9:49 Marlon Richert

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