diff --git a/src/builtins/complete.cpp b/src/builtins/complete.cpp index f219b39ac..a4c293722 100644 --- a/src/builtins/complete.cpp +++ b/src/builtins/complete.cpp @@ -33,7 +33,8 @@ static void builtin_complete_add2(const wchar_t *cmd, bool cmd_is_path, const wchar_t *short_opt, const wcstring_list_t &gnu_opts, const wcstring_list_t &old_opts, completion_mode_t result_mode, const wcstring_list_t &condition, - const wchar_t *comp, const wchar_t *desc, int flags) { + const wchar_t *comp, const wchar_t *desc, + complete_flags_t flags) { for (const wchar_t *s = short_opt; *s; s++) { complete_add(cmd, cmd_is_path, wcstring{*s}, option_type_short, result_mode, condition, comp, desc, flags); @@ -59,8 +60,8 @@ static void builtin_complete_add2(const wchar_t *cmd, bool cmd_is_path, const wc static void builtin_complete_add(const wcstring_list_t &cmds, const wcstring_list_t &paths, const wchar_t *short_opt, const wcstring_list_t &gnu_opt, const wcstring_list_t &old_opt, completion_mode_t result_mode, - const wcstring_list_t &condition, const wchar_t *comp, const wchar_t *desc, - int flags) { + const wcstring_list_t &condition, const wchar_t *comp, + const wchar_t *desc, complete_flags_t flags) { for (const wcstring &cmd : cmds) { builtin_complete_add2(cmd.c_str(), false /* not path */, short_opt, gnu_opt, old_opt, result_mode, condition, comp, desc, flags); @@ -428,8 +429,8 @@ maybe_t<int> builtin_complete(parser_t &parser, io_streams_t &streams, const wch parser.libdata().builtin_complete_current_commandline = false; } } else if (path.empty() && gnu_opt.empty() && short_opt.empty() && old_opt.empty() && !remove && - !*comp && !*desc && condition.empty() && wrap_targets.empty() && !result_mode.no_files && - !result_mode.force_files && !result_mode.requires_param) { + !*comp && !*desc && condition.empty() && wrap_targets.empty() && + !result_mode.no_files && !result_mode.force_files && !result_mode.requires_param) { // No arguments that would add or remove anything specified, so we print the definitions of // all matching completions. if (cmd_to_complete.empty()) { diff --git a/src/complete.h b/src/complete.h index a5546a19a..f8cca79d5 100644 --- a/src/complete.h +++ b/src/complete.h @@ -230,7 +230,8 @@ void completions_sort_and_prioritize(completion_list_t *comps, /// \param flags A set of completion flags void complete_add(const wchar_t *cmd, bool cmd_is_path, const wcstring &option, complete_option_type_t option_type, completion_mode_t result_mode, - wcstring_list_t condition, const wchar_t *comp, const wchar_t *desc, int flags); + wcstring_list_t condition, const wchar_t *comp, const wchar_t *desc, + complete_flags_t flags); /// Remove a previously defined completion. void complete_remove(const wcstring &cmd, bool cmd_is_path, const wcstring &option, @@ -261,7 +262,7 @@ bool complete_is_valid_argument(const wcstring &str, const wcstring &opt, const /// \param desc The description of the completion /// \param flags completion flags void append_completion(completion_list_t *completions, wcstring comp, wcstring desc = wcstring(), - int flags = 0, + complete_flags_t flags = 0, string_fuzzy_match_t match = string_fuzzy_match_t::exact_match()); /// Support for "wrap targets." A wrap target is a command that completes like another command. diff --git a/src/env.cpp b/src/env.cpp index e2c7c50fc..0dfb000ae 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -194,7 +194,7 @@ maybe_t<env_var_t> null_environment_t::get(const wcstring &key, env_mode_flags_t UNUSED(mode); return none(); } -wcstring_list_t null_environment_t::get_names(int flags) const { +wcstring_list_t null_environment_t::get_names(env_mode_flags_t flags) const { UNUSED(flags); return {}; } @@ -571,7 +571,7 @@ class env_scoped_impl_t : public environment_t, noncopyable_t { } maybe_t<env_var_t> get(const wcstring &key, env_mode_flags_t mode = ENV_DEFAULT) const override; - wcstring_list_t get_names(int flags) const override; + wcstring_list_t get_names(env_mode_flags_t flags) const override; perproc_data_t &perproc_data() { return perproc_data_; } const perproc_data_t &perproc_data() const { return perproc_data_; } @@ -835,7 +835,7 @@ maybe_t<env_var_t> env_scoped_impl_t::get(const wcstring &key, env_mode_flags_t return result; } -wcstring_list_t env_scoped_impl_t::get_names(int flags) const { +wcstring_list_t env_scoped_impl_t::get_names(env_mode_flags_t flags) const { const query_t query(flags); std::set<wcstring> names; @@ -1348,7 +1348,9 @@ maybe_t<env_var_t> env_stack_t::get(const wcstring &key, env_mode_flags_t mode) return acquire_impl()->get(key, mode); } -wcstring_list_t env_stack_t::get_names(int flags) const { return acquire_impl()->get_names(flags); } +wcstring_list_t env_stack_t::get_names(env_mode_flags_t flags) const { + return acquire_impl()->get_names(flags); +} int env_stack_t::set(const wcstring &key, env_mode_flags_t mode, wcstring_list_t vals) { // Historical behavior. diff --git a/src/env.h b/src/env.h index cab6e5a3a..07bf89fb0 100644 --- a/src/env.h +++ b/src/env.h @@ -187,7 +187,7 @@ class environment_t { public: virtual maybe_t<env_var_t> get(const wcstring &key, env_mode_flags_t mode = ENV_DEFAULT) const = 0; - virtual wcstring_list_t get_names(int flags) const = 0; + virtual wcstring_list_t get_names(env_mode_flags_t flags) const = 0; virtual ~environment_t(); /// Returns the PWD with a terminating slash. @@ -201,7 +201,7 @@ class null_environment_t : public environment_t { ~null_environment_t() override; maybe_t<env_var_t> get(const wcstring &key, env_mode_flags_t mode = ENV_DEFAULT) const override; - wcstring_list_t get_names(int flags) const override; + wcstring_list_t get_names(env_mode_flags_t flags) const override; }; /// A mutable environment which allows scopes to be pushed and popped. @@ -229,7 +229,7 @@ class env_stack_t final : public environment_t { maybe_t<env_var_t> get(const wcstring &key, env_mode_flags_t mode = ENV_DEFAULT) const override; /// Implementation of environment_t. - wcstring_list_t get_names(int flags) const override; + wcstring_list_t get_names(env_mode_flags_t flags) const override; /// Sets the variable with the specified name to the given values. int set(const wcstring &key, env_mode_flags_t mode, wcstring_list_t vals); diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 2f5e31604..341ac4ba1 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -2062,7 +2062,7 @@ struct test_environment_t : public environment_t { return none(); } - wcstring_list_t get_names(int flags) const override { + wcstring_list_t get_names(env_mode_flags_t flags) const override { UNUSED(flags); wcstring_list_t result; for (const auto &kv : vars) { @@ -2082,7 +2082,7 @@ struct pwd_environment_t : public test_environment_t { return test_environment_t::get(key, mode); } - wcstring_list_t get_names(int flags) const override { + wcstring_list_t get_names(env_mode_flags_t flags) const override { auto res = test_environment_t::get_names(flags); res.clear(); if (std::count(res.begin(), res.end(), L"PWD") == 0) { @@ -3197,7 +3197,7 @@ static void test_complete() { auto func_props = make_test_func_props(); struct test_complete_vars_t : environment_t { - wcstring_list_t get_names(int flags) const override { + wcstring_list_t get_names(env_mode_flags_t flags) const override { UNUSED(flags); return {L"Foo1", L"Foo2", L"Foo3", L"Bar1", L"Bar2", L"Bar3", L"alpha", L"ALPHA!", L"gamma1", L"GAMMA2"}; diff --git a/src/reader.cpp b/src/reader.cpp index 79e4318ac..9a5bbcbe0 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -1941,7 +1941,7 @@ const wchar_t *REPLACE_UNCLEAN = L"$*?({})"; /// Advanced tokens like those containing {}-style expansion can not at the moment be replaced, /// other than if the new token is already an exact replacement, e.g. if the COMPLETE_DONT_ESCAPE /// flag is set. -static bool reader_can_replace(const wcstring &in, int flags) { +static bool reader_can_replace(const wcstring &in, complete_flags_t flags) { if (flags & COMPLETE_DONT_ESCAPE) { return true; }