Nazri Ramliy <[email protected]> wrote:
> On Fri, Jul 6, 2018 at 8:59 PM, Dominique Pellé
> <[email protected]> wrote:
> >> Can you try interactively if happens when
> >> typing the Ex command :e ~a<C-a>
> >> where <C-a> is a single key for CTRL-A
> >>
> >> On which OS do you see the issue?
> >> Is it reproducible with other user names?
> >
> > I made an experiment on my machine:
> > :e ~p<c-a>
> > gives: :e ~pel proxy pulse (good!)
> >
> > Then I created a new user "pel2" and did:
> > : e ~p<c-a> gives :e ~pel pel2 proxy pulse (good)
> > : e ~pe<c-a> gives :e ~pel pel2 (good)
> > : e ~pel<c-a> gives :e /home/pel/ (does not look right!)
> >
> > I expected to get :e ~pel pel2 in the last case.
> >
> > In your case, I suspect that you have a user name called "a"
> > which is triggering the bug.
> >
> > It looks like a bug in vim found by the test.
>
> Yup I do have a user called "a" on the machine. This is on linux
> (ubuntu 16.04.4).
>
> The bug don't appear if I comment out the entry for the user "a" in
> /etc/passwd.
>
> Also I see this weird behavior:
>
> $ sudo vi /etc/passwd
> :e ~a<c-a> gives /home/a/ (buggy as expected)
>
> now without closing the file comment out the entry for the "a" user
> and save the file and reattempt the completion
>
> :e ~a<c-a> nothing suggested, ":e ~a" remains. I expect it list the
> usernames that starts with "a".
>
> Now undo the changes to the file and quit vim and open it again in vim
> but this time immediately comment out the entry for "a":
>
> $ sudo vi /etc/passwd
> comment out the entry for "a"
>
> :e ~a<c-a> gives the expected result :e ~avahi avahi-autoipd ayie
>
> nazri
Hi Nazri
The attached patch "fix-user-name-compl-8.1.155.patch"
should fix the bug. Can you try it?
It's good to see that recently added tests discover bugs.
Thanks!
Dominique
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index fec3a8e37..40a349517 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3764,7 +3764,7 @@ set_one_cmd_context(
* A full match ~user<Tab> will be replaced by user's home
* directory i.e. something like ~user<Tab> -> /home/user/ */
if (*p == NUL && p > xp->xp_pattern + 1
- && match_user(xp->xp_pattern + 1) == 1)
+ && (match_user(xp->xp_pattern + 1) & 1))
{
xp->xp_context = EXPAND_USER;
++xp->xp_pattern;
diff --git a/src/misc1.c b/src/misc1.c
index 5242ca572..c102636a4 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -4826,22 +4826,23 @@ get_users(expand_T *xp UNUSED, int idx)
* 0 if name does not match any user name.
* 1 if name partially matches the beginning of a user name.
* 2 is name fully matches a user name.
+ * 3 is name fully matches a user name and partially matches another.
*/
int match_user(char_u* name)
{
int i;
int n = (int)STRLEN(name);
- int result = 0;
+ int match = 0;
init_users();
for (i = 0; i < ga_users.ga_len; i++)
{
if (STRCMP(((char_u **)ga_users.ga_data)[i], name) == 0)
- return 2; /* full match */
- if (STRNCMP(((char_u **)ga_users.ga_data)[i], name, n) == 0)
- result = 1; /* partial match */
+ match |= 2; /* full match */
+ else if (STRNCMP(((char_u **)ga_users.ga_data)[i], name, n) == 0)
+ match |= 1; /* partial match */
}
- return result;
+ return match;
}
#endif