Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit Fix file name auto completion in one specific case.



details:   https://anonhg.NetBSD.org/src/rev/05a660aab6c6
branches:  trunk
changeset: 818785:05a660aab6c6
user:      abhinav <abhinav%NetBSD.org@localhost>
date:      Mon Oct 31 17:46:32 2016 +0000

description:
Fix file name auto completion in one specific case.

For example if you do
$mkdir -p /tmp/dir1/dir2

Then:
$ls /tmp/di <TAB> auto completes to
$ls /tmp/dir1/

Hitting <TAB> again auto completes to
$ls /tmp/dir1/dir2

Whereas it should auto complete to
$ls /tmp/dir1/dir2/


Essentially, in cases like above where you have to hit <TAB> twice to get
to the match and there is only one match (because only one file/sub-directory) then
auto complete doesn't work correctly. It doesn't append a trailing slash (in case
of directory) or a space (in case of a file) to the match name.

I have tested file name completion in sh(1) and symbol completion in gdb after
this change.

diffstat:

 lib/libedit/filecomplete.c |  9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diffs (37 lines):

diff -r b25645c57fa7 -r 05a660aab6c6 lib/libedit/filecomplete.c
--- a/lib/libedit/filecomplete.c        Mon Oct 31 16:23:03 2016 +0000
+++ b/lib/libedit/filecomplete.c        Mon Oct 31 17:46:32 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecomplete.c,v 1.43 2016/04/11 00:50:13 christos Exp $       */
+/*     $NetBSD: filecomplete.c,v 1.44 2016/10/31 17:46:32 abhinav Exp $        */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: filecomplete.c,v 1.43 2016/04/11 00:50:13 christos Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.44 2016/10/31 17:46:32 abhinav Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -482,8 +482,6 @@
                            ct_decode_string(matches[0], &el->el_scratch));
                }
 
-               if (what_to_do == '?')
-                       goto display_matches;
 
                if (matches[2] == NULL &&
                    (matches[1] == NULL || strcmp(matches[0], matches[1]) == 0)) {
@@ -495,8 +493,7 @@
                        el_winsertstr(el,
                            ct_decode_string((*app_func)(matches[0]),
                            &el->el_scratch));
-               } else if (what_to_do == '!') {
-    display_matches:
+               } else if (what_to_do == '!' || what_to_do == '?') {
                        /*
                         * More than one match and requested to list possible
                         * matches.



Home | Main Index | Thread Index | Old Index