commit 4821ac645f2abf9d4e2c638eb5db412e65863eba
parent 6e6c80b1812a7504c9f415bb4326a48a98128149
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Thu, 11 Oct 2007 15:49:08 +0000
in input_tab(), disable completion of usernames, directories, and
filenames if the cursor isn't at the end of the line, as it can lead to
odd behavior (e.g. adding a copy of the entire match to the middle of
the line instead of just the uncompleted part of the match)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4176 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -9,6 +9,11 @@
* files.c (cwd_tab_completion): Remove unneeded assert.
* files.c (username_tab_completion, cwd_tab_completion): Rename
variable buflen to buf_len, for consistency.
+ * files.c (input_tab): Disable completion of usernames,
+ directories, and filenames if the cursor isn't at the end of the
+ line, as it can lead to odd behavior (e.g. adding a copy of the
+ entire match to the middle of the line instead of just the
+ uncompleted part of the match).
2007-10-05 David Lawrence Ramsey <pooka109@gmail.com>
diff --git a/src/files.c b/src/files.c
@@ -2287,7 +2287,7 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t
char *input_tab(char *buf, bool allow_files, size_t *place, bool
*lastwastab, void (*refresh_func)(void), bool *list)
{
- size_t num_matches = 0;
+ size_t num_matches = 0, buf_len;
char **matches = NULL;
assert(buf != NULL && place != NULL && *place <= strlen(buf) && lastwastab != NULL && refresh_func != NULL && list != NULL);
@@ -2309,7 +2309,9 @@ char *input_tab(char *buf, bool allow_files, size_t *place, bool
matches = cwd_tab_completion(buf, allow_files, &num_matches,
*place);
- if (num_matches == 0)
+ buf_len = strlen(buf);
+
+ if (num_matches == 0 || *place != buf_len)
beep();
else {
size_t match, common_len = 0;
@@ -2368,8 +2370,6 @@ char *input_tab(char *buf, bool allow_files, size_t *place, bool
* twice in succession with no statusbar changes to see a match
* list. */
if (common_len != *place) {
- size_t buf_len = strlen(buf);
-
*lastwastab = FALSE;
buf = charealloc(buf, common_len + buf_len - *place + 1);
charmove(buf + common_len, buf + *place, buf_len -