GNU bug report logs -
#65137
29.1; completion-substring-try-completion doesn't return the longest common substring
Previous Next
Reported by: Spencer Baugh <sbaugh <at> janestreet.com>
Date: Mon, 7 Aug 2023 23:25:01 UTC
Severity: normal
Found in version 29.1
Fixed in version 30.1
Done: Spencer Baugh <sbaugh <at> janestreet.com>
Bug is archived. No further changes may be made.
Full log
Message #14 received at 65137 <at> debbugs.gnu.org (full text, mbox):
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Date: Mon, 07 Aug 2023 19:24:15 -0400
>
>
> The substring completion style differs from the "basic" style by
> performing completion at the start of the input string. So for example,
> both of these are valid completions for "bar":
>
> (completion-substring-all-completions "bar" '("foobar" "foobarbaz") #'identity (length "bar"))
> -> ("foobarbaz" "foobar" . 0)
>
> However, the substring completion style's try-completion implementation
> does not reflect this. Since "foobar" is a prefix of all the valid
> completions, it should be returned by try-completion. But it is not,
> regardless of the location of point:
>
> (completion-substring-try-completion "bar" '("foobar" "foobarbaz") #'identity 0)
> -> ("bar" . 3)
>
> (completion-substring-try-completion "bar" '("foobar" "foobarbaz") #'identity (length "bar"))
> -> ("bar" . 3)
>
> This breaks completion when one completion candidate is a prefix of
> other completion candidates. The recourse is moving point to the start
> of the input, so that the "basic" completion style takes over, which
> will correctly insert the common prefix:
>
> (completion-basic-try-completion "bar" '("foobar" "foobarbaz") #'identity 0)
> -> ("foobar" . 6)
>
> However, even this does not work in the project-file and xref-location
> completion categories, for which the "basic" style is not included in
> completion-category-defaults. For such completion categories, there's
> simply no way to use completion to insert a common prefix. This is bad,
> because a filename or identifier might easily be a prefix of another
> filename or identifier.
>
> The solution is completion-substring-try-completion to be fixed to
> insert these common prefixes. I'll try and fix this, although the code
> is a bit intimidating.
Adding Stefan, in case he has some comments or ideas.
This bug report was last modified 1 year and 281 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.