mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-25 11:36:21 +00:00
fix: Fix file autocompletion bugs and restore cycling
Fix several issues in cmd_ac_complete_filepath:
* Prevent a segfault when input is empty.
* Fix a double free where acstring was managed by both auto_gchar and GArray.
* Fix a memory leak when reassigning inpcp during quote stripping.
* Restore the ability to cycle through files on repeated TAB presses by
caching the last input and skipping updates if the input is already a
known completion.
* Preserve user input style (e.g. ~, ./) in autocompletion strings to
ensure matches are correctly displayed and filtered.
Bug got introduced when "cleaning" code with new compiler flags and
sanitizers: aec8e48268.
Add unit tests so this doesn't happen again.
Before that commit we didn't use the static variable but used
autocomplete_update instead. Now we avoid redundat updates and preserve
the state across tab presses. We should look at this again later.
Fix https://github.com/profanity-im/profanity/issues/2098
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "command/test_cmd_bookmark.h"
|
||||
#include "command/test_cmd_join.h"
|
||||
#include "xmpp/test_muc.h"
|
||||
#include "command/test_cmd_ac.h"
|
||||
#include "command/test_cmd_roster.h"
|
||||
#include "command/test_cmd_disconnect.h"
|
||||
#include "xmpp/test_form.h"
|
||||
@@ -96,6 +97,10 @@ main(int argc, char* argv[])
|
||||
cmocka_unit_test(unique_filename_from_url__tests__table_driven),
|
||||
cmocka_unit_test(string_to_verbosity__returns__correct_values),
|
||||
cmocka_unit_test(get_expanded_path__returns__expanded),
|
||||
cmocka_unit_test_setup_teardown(cmd_ac_complete_filepath__segfaults_when_empty, load_preferences, close_preferences),
|
||||
cmocka_unit_test_setup_teardown(cmd_ac_complete_filepath__finds_files_in_current_dir, load_preferences, close_preferences),
|
||||
cmocka_unit_test_setup_teardown(cmd_ac_complete_filepath__finds_files_with_dot_slash, load_preferences, close_preferences),
|
||||
cmocka_unit_test_setup_teardown(cmd_ac_complete_filepath__cycles_through_files, load_preferences, close_preferences),
|
||||
cmocka_unit_test(strtoi_range__returns__true_for_valid_input),
|
||||
cmocka_unit_test(strtoi_range__returns__false_for_out_of_range),
|
||||
cmocka_unit_test(strtoi_range__returns__false_for_invalid_input),
|
||||
|
||||
Reference in New Issue
Block a user