diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compgen.c | 1 | ||||
-rw-r--r-- | src/main.c | 13 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/compgen.c b/src/compgen.c index b4bcc4c..9e9f422 100644 --- a/src/compgen.c +++ b/src/compgen.c @@ -183,6 +183,7 @@ void compgen_history_sort(struct string_vec *programs, struct history *history) for (size_t i = 0; i < history->count; i++) { char **res = string_vec_find(programs, history->buf[i].name); if (res == NULL) { + log_debug("History entry \"%s\" not found.\n", history->buf[i].name); continue; } free(*res); @@ -1347,12 +1347,15 @@ int main(int argc, char *argv[]) string_vec_add(&tofi.window.entry.commands, line); } free(line); - if (tofi.history_file[0] == 0) { - tofi.use_history = false; - } else { - tofi.window.entry.history = history_load(tofi.history_file); + if (tofi.use_history) { + if (tofi.history_file[0] == 0) { + tofi.use_history = false; + } else { + string_vec_sort(&tofi.window.entry.commands); + tofi.window.entry.history = history_load(tofi.history_file); + compgen_history_sort(&tofi.window.entry.commands, &tofi.window.entry.history); + } } - compgen_history_sort(&tofi.window.entry.commands, &tofi.window.entry.history); } tofi.window.entry.results = string_vec_copy(&tofi.window.entry.commands); |