diff --git a/lib/cmdledit.g b/lib/cmdledit.g index f914b13447..fa01ba1d22 100644 --- a/lib/cmdledit.g +++ b/lib/cmdledit.g @@ -967,8 +967,9 @@ GAPInfo.CommandLineEditFunctions.Functions.Completion := function(l) if (not IsBound(cf.tabcompnam) and cf.tabcount = 2) or (IsBound(cf.tabcompnam) and cf.tabcount in [2,4]) then if Length(cand) > 0 then + # we prepend the partial word which was completed return GAPInfo.CommandLineEditFunctions.Functions.DisplayMatches( - Set(cand)); + Concatenation([word], Set(cand))); else # ring the bell return GAPInfo.CommandLineEditFunctions.Functions.RingBell(); diff --git a/src/sysfiles.c b/src/sysfiles.c index 20e3f1acc4..ac6ca58f37 100644 --- a/src/sysfiles.c +++ b/src/sysfiles.c @@ -2117,15 +2117,17 @@ int GAP_rl_func(int count, int key) if (hook == 1) { /* display matches */ if (!IS_LIST(data)) return 0; - dlen = LEN_LIST(data); - char **strs = (char**)malloc((dlen+1) * sizeof(char*)); + /* -1, because first is word to be completed */ + dlen = LEN_LIST(data)-1; + /* +2, must be in 'argv' format, terminated by 0 */ + char **strs = (char**)calloc(dlen+2, sizeof(char*)); max = 0; - for (i=1; i <= dlen; i++) { - if (!IsStringConv(ELM_LIST(data, i))) { + for (i=0; i <= dlen; i++) { + if (!IsStringConv(ELM_LIST(data, i+1))) { free(strs); return 0; } - strs[i] = CSTR_STRING(ELM_LIST(data, i)); + strs[i] = CSTR_STRING(ELM_LIST(data, i+1)); if (max < strlen(strs[i])) max = strlen(strs[i]); } rl_display_match_list(strs, dlen, max); diff --git a/src/system.c b/src/system.c index aff93b5d73..699c488ba0 100644 --- a/src/system.c +++ b/src/system.c @@ -1160,6 +1160,7 @@ void InitSystem ( InitSysFiles(); #ifdef HAVE_LIBREADLINE + rl_readline_name = "GAP"; rl_initialize (); #endif