Module Name: src
Committed By: abhinav
Date: Mon Oct 31 17:46:32 UTC 2016
Modified Files:
src/lib/libedit: filecomplete.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/lib/libedit/filecomplete.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libedit/filecomplete.c
diff -u src/lib/libedit/filecomplete.c:1.43 src/lib/libedit/filecomplete.c:1.44
--- src/lib/libedit/filecomplete.c:1.43 Mon Apr 11 00:50:13 2016
+++ src/lib/libedit/filecomplete.c Mon Oct 31 17:46:32 2016
@@ -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 @@ fn_complete(EditLine *el,
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 @@ fn_complete(EditLine *el,
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.