fix real-life example From: Andrew Kudryashov <andrewinsilenthill@gmail.com>
in <CABNd6wz3SSRWamUNQ-BNcp7z0pthOR156=Zy3qBYmXhTjvoYsg@mail.gmail.com> but by a different (cheaper) method than the one in his patch from message-id <CABNd6ww7zFUQ4Ho2zQQzQyERy==8Hqg_y12Acmj1sF6ka4b4KQ@mail.gmail.com>: when completing, always replace the olen text with the new one, and only then take the length of the x_expand()ed nlen text to compare and check whether to set completed=true; this also means: $ ls foo\+/<tab> ↓ $ ls foo+/ this matches reality even better and saves us a couple of string traversals
This commit is contained in:
8
edit.c
8
edit.c
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.228 2012/03/23 21:15:34 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.229 2012/03/23 21:34:47 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in later versions we might use libtermcap for this, but since external
|
* in later versions we might use libtermcap for this, but since external
|
||||||
@ -2721,14 +2721,14 @@ do_complete(
|
|||||||
}
|
}
|
||||||
olen = end - start;
|
olen = end - start;
|
||||||
nlen = x_longest_prefix(nwords, words);
|
nlen = x_longest_prefix(nwords, words);
|
||||||
/* complete */
|
/* always complete */
|
||||||
if (nwords == 1 || nlen > olen) {
|
|
||||||
x_goto(xbuf + start);
|
x_goto(xbuf + start);
|
||||||
x_delete(olen, false);
|
x_delete(olen, false);
|
||||||
x_escape(words[0], nlen, x_do_ins);
|
x_escape(words[0], nlen, x_do_ins);
|
||||||
x_adjust();
|
x_adjust();
|
||||||
|
/* check if we did add something */
|
||||||
|
if (xcp - (xbuf + start) > olen)
|
||||||
completed = true;
|
completed = true;
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* append a space if this is a single non-directory match
|
* append a space if this is a single non-directory match
|
||||||
* and not a parameter or homedir substitution
|
* and not a parameter or homedir substitution
|
||||||
|
Reference in New Issue
Block a user