diff options
author | Anthony Mallet <anthony.mallet@laas.fr> | 2020-09-29 16:51:14 +0200 |
---|---|---|
committer | Anthony Mallet <anthony.mallet@laas.fr> | 2020-09-29 17:33:21 +0200 |
commit | 820b8dbcb4553630499b687901ef1d9de0114ce1 (patch) | |
tree | 75f711521da27e5d941feb70f9668b8abb14fd79 | |
parent | b839ccde14237e9142d31b328f3383009b1e9c76 (diff) | |
download | eltclsh-820b8dbcb4553630499b687901ef1d9de0114ce1.tar.gz |
If partial completion was added, redisplay before displaying remaining items
When there is a common prefix in completions, but the completion list is longer
than the confirmation threshold, redisplay the command line with the common
prefix added before asking for confirmation.
-rw-r--r-- | src/complete.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/src/complete.c b/src/complete.c index bc33b66..f00499a 100644 --- a/src/complete.c +++ b/src/complete.c @@ -120,28 +120,6 @@ elTclCompletion(EditLine *el, int ch) return CC_REFRESH; } - if (count-2 > iinfo->completionQueryItems && iinfo->completionQueryItems) { - /* ask user */ - printf("\nDisplay all %d possibilit%s? [y/n] ", - count-2, count>3?"ies":"y"); - fflush(stdout); - - if (el_getc(iinfo->el, &c) <= 0) { - fputc('\n', stdout); - Tcl_DecrRefCount(cmdLine); - return CC_REDISPLAY; - } - - if (c != 'y' && c != 'Y') { - fputc(c, stdout); - fputc('\n', stdout); - Tcl_DecrRefCount(cmdLine); - return CC_REDISPLAY; - } - - fputc(c, stdout); - } - /* find the smallest common part in every matches */ Tcl_ListObjIndex(iinfo->interp, matches[2], 0, &cmd[0]); string0 = Tcl_GetStringFromObj(cmd[0], &length0); @@ -171,6 +149,27 @@ elTclCompletion(EditLine *el, int ch) el_insertstr(el, str); } + /* ask user if too many items are to be displayed */ + if (count-2 > iinfo->completionQueryItems && iinfo->completionQueryItems) { + if (end > linfo->cursor - linfo->buffer - start) + return CC_REDISPLAY; + + printf("\nDisplay all %d possibilit%s? [y/n] ", + count-2, count>3?"ies":"y"); + fflush(stdout); + + if (el_getc(iinfo->el, &c) <= 0) { + fputc('\n', stdout); + return CC_REDISPLAY; + } + + if (c != 'y' && c != 'Y') { + fputc(c, stdout); + fputc('\n', stdout); + return CC_REDISPLAY; + } + + fputc(c, stdout); } /* find the biggest match (for multicol display) */ |