From: David Lawrence Ramsey Date: Thu, 11 Oct 2007 15:49:08 +0000 (+0000) Subject: in input_tab(), disable completion of usernames, directories, and X-Git-Tag: v2.0.7~30 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=7e9b345010409062299cf4c5a7b72af604b66580;p=nano.git 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/branches/nano_2_0_branch/nano@4176 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 9693b8bf..434fdadd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -53,6 +53,12 @@ CVS code - cwd_tab_completion() - Remove unneeded assert. (DLR) - Rename variable buflen to buf_len, for consistency. (DLR) + 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). (DLR) - nano.c: version() - Display copyright notices. (DLR) diff --git a/src/files.c b/src/files.c index bc6b9e3d..da0ff9cd 100644 --- 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 -