complete_add to take const wcstring& instead of const wchar_t *

An oversight that this wasn't done earlier. No functional change here.
This commit is contained in:
ridiculousfish 2022-05-31 12:29:10 -07:00
parent 738a6df77d
commit 46678f2eac
3 changed files with 7 additions and 8 deletions

View File

@ -30,7 +30,7 @@
// complete_add function only accepts one short switch and one long switch.
/// Silly function.
static void builtin_complete_add2(const wchar_t *cmd, bool cmd_is_path, const wchar_t *short_opt,
static void builtin_complete_add2(const wcstring &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,
@ -63,13 +63,13 @@ static void builtin_complete_add(const wcstring_list_t &cmds, const wcstring_lis
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);
builtin_complete_add2(cmd, false /* not path */, short_opt, gnu_opt, old_opt, result_mode,
condition, comp, desc, flags);
}
for (const wcstring &path : paths) {
builtin_complete_add2(path.c_str(), true /* is path */, short_opt, gnu_opt, old_opt,
result_mode, condition, comp, desc, flags);
builtin_complete_add2(path, true /* is path */, short_opt, gnu_opt, old_opt, result_mode,
condition, comp, desc, flags);
}
}

View File

@ -1731,11 +1731,10 @@ void append_completion(completion_list_t *completions, wcstring comp, wcstring d
completions->emplace_back(std::move(comp), std::move(desc), match, flags);
}
void complete_add(const wchar_t *cmd, bool cmd_is_path, const wcstring &option,
void complete_add(const wcstring &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,
complete_flags_t flags) {
assert(cmd && "Null command");
// option should be empty iff the option type is arguments only.
assert(option.empty() == (option_type == option_type_args_only));

View File

@ -224,7 +224,7 @@ void completions_sort_and_prioritize(completion_list_t *comps,
/// \param condition a command to be run to check it this completion should be used. If \c condition
/// is empty, the completion is always used.
/// \param flags A set of completion flags
void complete_add(const wchar_t *cmd, bool cmd_is_path, const wcstring &option,
void complete_add(const wcstring &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,
complete_flags_t flags);