diff options
author | Phil Jones <philj56@gmail.com> | 2022-11-19 15:18:40 +0000 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2022-11-19 15:18:40 +0000 |
commit | 9ceceeb59a95919e5fe09338dc27e4fac0b5aa24 (patch) | |
tree | adc3f2a822d24420b6b553e98c834257f620ee54 /src/main.c | |
parent | d04ca544d6845fc655cd4ba55e134de6bead6a2d (diff) |
Sort items in normal tofi mode when using history.
This is a short-term workaround for history sorting not working, due to
the binary search used to find exiting items relying on the input
already being sorted.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -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); |