mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Use completion_list_t naming everywhere
std::vector<completion_t> -> completion_list_t
This commit is contained in:
parent
98e714f98f
commit
4bb18eaf42
17 changed files with 82 additions and 91 deletions
|
@ -479,7 +479,7 @@ wcstring_list_t builtin_get_names() {
|
|||
}
|
||||
|
||||
/// Insert all builtin names into list.
|
||||
void builtin_get_names(std::vector<completion_t> *list) {
|
||||
void builtin_get_names(completion_list_t *list) {
|
||||
assert(list != nullptr);
|
||||
list->reserve(list->size() + BUILTIN_COUNT);
|
||||
for (const auto &builtin_data : builtin_datas) {
|
||||
|
|
|
@ -13,6 +13,7 @@ class parser_t;
|
|||
class proc_status_t;
|
||||
class output_stream_t;
|
||||
struct io_streams_t;
|
||||
using completion_list_t = std::vector<completion_t>;
|
||||
|
||||
/// Data structure to describe a builtin.
|
||||
struct builtin_data_t {
|
||||
|
@ -83,7 +84,7 @@ bool builtin_exists(const wcstring &cmd);
|
|||
proc_status_t builtin_run(parser_t &parser, int job_pgid, wchar_t **argv, io_streams_t &streams);
|
||||
|
||||
wcstring_list_t builtin_get_names();
|
||||
void builtin_get_names(std::vector<completion_t> *list);
|
||||
void builtin_get_names(completion_list_t *list);
|
||||
const wchar_t *builtin_get_desc(const wcstring &name);
|
||||
|
||||
wcstring builtin_help_get(parser_t &parser, const wchar_t *cmd);
|
||||
|
|
|
@ -347,7 +347,7 @@ int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
if (!have_do_complete_param)
|
||||
parser.libdata().builtin_complete_current_commandline = true;
|
||||
|
||||
std::vector<completion_t> comp;
|
||||
completion_list_t comp;
|
||||
complete(do_complete_param, &comp, completion_request_t::fuzzy_match, parser.vars(),
|
||||
parser.shared());
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ __attribute__((always_inline)) static inline bool compare_completions_by_tilde(
|
|||
}
|
||||
|
||||
/// Unique the list of completions, without perturbing their order.
|
||||
static void unique_completions_retaining_order(std::vector<completion_t> *comps) {
|
||||
static void unique_completions_retaining_order(completion_list_t *comps) {
|
||||
std::unordered_set<wcstring> seen;
|
||||
seen.reserve(comps->size());
|
||||
auto pred = [&seen](const completion_t &c) {
|
||||
|
@ -268,8 +268,7 @@ static void unique_completions_retaining_order(std::vector<completion_t> *comps)
|
|||
comps->erase(std::remove_if(comps->begin(), comps->end(), pred), comps->end());
|
||||
}
|
||||
|
||||
void completions_sort_and_prioritize(std::vector<completion_t> *comps,
|
||||
completion_request_flags_t flags) {
|
||||
void completions_sort_and_prioritize(completion_list_t *comps, completion_request_flags_t flags) {
|
||||
// Find the best match type.
|
||||
fuzzy_match_type_t best_type = fuzzy_match_none;
|
||||
for (const auto &comp : *comps) {
|
||||
|
@ -326,7 +325,7 @@ class completer_t {
|
|||
const completion_request_flags_t flags;
|
||||
|
||||
/// The output completions.
|
||||
std::vector<completion_t> completions;
|
||||
completion_list_t completions;
|
||||
|
||||
/// Table of completions conditions that have already been tested and the corresponding test
|
||||
/// results.
|
||||
|
@ -374,7 +373,7 @@ class completer_t {
|
|||
bool condition_test(const wcstring &condition);
|
||||
|
||||
void complete_strings(const wcstring &wc_escaped, const description_func_t &desc_func,
|
||||
const std::vector<completion_t> &possible_comp, complete_flags_t flags);
|
||||
const completion_list_t &possible_comp, complete_flags_t flags);
|
||||
|
||||
expand_flags_t expand_flags() const {
|
||||
// Never do command substitution in autosuggestions. Sadly, we also can't yet do job
|
||||
|
@ -402,14 +401,14 @@ class completer_t {
|
|||
|
||||
void perform();
|
||||
|
||||
std::vector<completion_t> acquire_completions() { return std::move(completions); }
|
||||
completion_list_t acquire_completions() { return std::move(completions); }
|
||||
};
|
||||
|
||||
// Autoloader for completions.
|
||||
static owning_lock<autoload_t> completion_autoloader{autoload_t(L"fish_complete_path")};
|
||||
|
||||
/// Create a new completion entry.
|
||||
void append_completion(std::vector<completion_t> *completions, wcstring comp, wcstring desc,
|
||||
void append_completion(completion_list_t *completions, wcstring comp, wcstring desc,
|
||||
complete_flags_t flags, string_fuzzy_match_t &&match) {
|
||||
completions->emplace_back(std::move(comp), std::move(desc), match, flags);
|
||||
}
|
||||
|
@ -555,8 +554,7 @@ static void parse_cmd_string(const wcstring &str, wcstring *path, wcstring *cmd,
|
|||
/// @param flags
|
||||
/// The flags
|
||||
void completer_t::complete_strings(const wcstring &wc_escaped, const description_func_t &desc_func,
|
||||
const std::vector<completion_t> &possible_comp,
|
||||
complete_flags_t flags) {
|
||||
const completion_list_t &possible_comp, complete_flags_t flags) {
|
||||
wcstring tmp = wc_escaped;
|
||||
if (!expand_one(tmp,
|
||||
this->expand_flags() | expand_flag::skip_cmdsubst | expand_flag::skip_wildcards,
|
||||
|
@ -678,7 +676,7 @@ static wcstring complete_function_desc(const wcstring &fn) {
|
|||
///
|
||||
/// \param str_cmd the command string to find completions for
|
||||
void completer_t::complete_cmd(const wcstring &str_cmd) {
|
||||
std::vector<completion_t> possible_comp;
|
||||
completion_list_t possible_comp;
|
||||
|
||||
// Append all possible executables
|
||||
expand_result_t result =
|
||||
|
@ -720,7 +718,7 @@ void completer_t::complete_cmd(const wcstring &str_cmd) {
|
|||
|
||||
void completer_t::complete_abbr(const wcstring &cmd) {
|
||||
std::map<wcstring, wcstring> abbrs = get_abbreviations(vars);
|
||||
std::vector<completion_t> possible_comp;
|
||||
completion_list_t possible_comp;
|
||||
possible_comp.reserve(abbrs.size());
|
||||
for (const auto &kv : abbrs) {
|
||||
possible_comp.emplace_back(kv.first);
|
||||
|
@ -765,8 +763,7 @@ void completer_t::complete_from_args(const wcstring &str, const wcstring &args,
|
|||
eflags |= expand_flag::skip_cmdsubst;
|
||||
}
|
||||
|
||||
std::vector<completion_t> possible_comp =
|
||||
parser_t::expand_argument_list(args, eflags, vars, parser);
|
||||
completion_list_t possible_comp = parser_t::expand_argument_list(args, eflags, vars, parser);
|
||||
|
||||
if (parser) {
|
||||
parser->libdata().is_interactive = saved_interactive;
|
||||
|
@ -1139,7 +1136,7 @@ void completer_t::complete_param_expand(const wcstring &str, bool do_file,
|
|||
// so any quoting or braces gets lost.
|
||||
// See #4954.
|
||||
const wcstring sep_string = wcstring(str, sep_index + 1);
|
||||
std::vector<completion_t> local_completions;
|
||||
completion_list_t local_completions;
|
||||
if (expand_string(sep_string, &local_completions, flags, vars, parser, nullptr) ==
|
||||
expand_result_t::error) {
|
||||
debug(3, L"Error while expanding string '%ls'", sep_string.c_str());
|
||||
|
@ -1598,7 +1595,7 @@ void completer_t::perform() {
|
|||
parser->libdata().transient_commandlines.push_back(unaliased_cmd);
|
||||
cleanup_t remove_transient(
|
||||
[&] { parser->libdata().transient_commandlines.pop_back(); });
|
||||
std::vector<completion_t> comp;
|
||||
completion_list_t comp;
|
||||
complete(unaliased_cmd, &comp, completion_request_t::fuzzy_match,
|
||||
parser->vars(), parser->shared());
|
||||
this->completions.insert(completions.end(), comp.begin(), comp.end());
|
||||
|
@ -1638,7 +1635,7 @@ void completer_t::perform() {
|
|||
mark_completions_duplicating_arguments(current_token, tokens);
|
||||
}
|
||||
|
||||
void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> *out_comps,
|
||||
void complete(const wcstring &cmd_with_subcmds, completion_list_t *out_comps,
|
||||
completion_request_flags_t flags, const environment_t &vars,
|
||||
const std::shared_ptr<parser_t> &parser) {
|
||||
// Determine the innermost subcommand.
|
||||
|
|
|
@ -101,6 +101,8 @@ class completion_t {
|
|||
void prepend_token_prefix(const wcstring &prefix);
|
||||
};
|
||||
|
||||
using completion_list_t = std::vector<completion_t>;
|
||||
|
||||
enum class completion_request_t {
|
||||
autosuggestion, // indicates the completion is for an autosuggestion
|
||||
descriptions, // indicates that we want descriptions
|
||||
|
@ -124,7 +126,7 @@ enum complete_option_type_t {
|
|||
|
||||
/// Sorts and remove any duplicate completions in the completion list, then puts them in priority
|
||||
/// order.
|
||||
void completions_sort_and_prioritize(std::vector<completion_t> *comps,
|
||||
void completions_sort_and_prioritize(completion_list_t *comps,
|
||||
completion_request_flags_t flags = {});
|
||||
|
||||
/// Add a completion.
|
||||
|
@ -171,9 +173,8 @@ void complete_remove_all(const wcstring &cmd, bool cmd_is_path);
|
|||
|
||||
/// Find all completions of the command cmd, insert them into out.
|
||||
class parser_t;
|
||||
void complete(const wcstring &cmd, std::vector<completion_t> *out_comps,
|
||||
completion_request_flags_t flags, const environment_t &vars,
|
||||
const std::shared_ptr<parser_t> &parser);
|
||||
void complete(const wcstring &cmd, completion_list_t *out_comps, completion_request_flags_t flags,
|
||||
const environment_t &vars, const std::shared_ptr<parser_t> &parser);
|
||||
|
||||
/// Return a list of all current completions.
|
||||
wcstring complete_print();
|
||||
|
@ -191,8 +192,8 @@ bool complete_is_valid_argument(const wcstring &str, const wcstring &opt, const
|
|||
/// \param comp The completion string
|
||||
/// \param desc The description of the completion
|
||||
/// \param flags completion flags
|
||||
void append_completion(std::vector<completion_t> *completions, wcstring comp,
|
||||
wcstring desc = wcstring(), int flags = 0,
|
||||
void append_completion(completion_list_t *completions, wcstring comp, wcstring desc = wcstring(),
|
||||
int flags = 0,
|
||||
string_fuzzy_match_t &&match = string_fuzzy_match_t(fuzzy_match_exact));
|
||||
|
||||
/// Support for "wrap targets." A wrap target is a command that completes like another command.
|
||||
|
|
|
@ -268,7 +268,7 @@ static size_t parse_slice(const wchar_t *in, wchar_t **end_ptr, std::vector<long
|
|||
/// Note: last_idx is considered to be where it previously finished procesisng. This means it
|
||||
/// actually starts operating on last_idx-1. As such, to process a string fully, pass string.size()
|
||||
/// as last_idx instead of string.size()-1.
|
||||
static bool expand_variables(wcstring instr, std::vector<completion_t> *out, size_t last_idx,
|
||||
static bool expand_variables(wcstring instr, completion_list_t *out, size_t last_idx,
|
||||
const environment_t &vars, parse_error_list_t *errors) {
|
||||
const size_t insize = instr.size();
|
||||
|
||||
|
@ -466,7 +466,7 @@ static bool expand_variables(wcstring instr, std::vector<completion_t> *out, siz
|
|||
|
||||
/// Perform brace expansion.
|
||||
static expand_result_t expand_braces(const wcstring &instr, expand_flags_t flags,
|
||||
std::vector<completion_t> *out, parse_error_list_t *errors) {
|
||||
completion_list_t *out, parse_error_list_t *errors) {
|
||||
bool syntax_error = false;
|
||||
int brace_count = 0;
|
||||
|
||||
|
@ -575,7 +575,7 @@ static expand_result_t expand_braces(const wcstring &instr, expand_flags_t flags
|
|||
}
|
||||
|
||||
/// Perform cmdsubst expansion.
|
||||
static bool expand_cmdsubst(wcstring input, parser_t &parser, std::vector<completion_t> *out_list,
|
||||
static bool expand_cmdsubst(wcstring input, parser_t &parser, completion_list_t *out_list,
|
||||
parse_error_list_t *errors) {
|
||||
wchar_t *paren_begin = nullptr, *paren_end = nullptr;
|
||||
wchar_t *tail_begin = nullptr;
|
||||
|
@ -649,7 +649,7 @@ static bool expand_cmdsubst(wcstring input, parser_t &parser, std::vector<comple
|
|||
|
||||
// Recursively call ourselves to expand any remaining command substitutions. The result of this
|
||||
// recursive call using the tail of the string is inserted into the tail_expand array list
|
||||
std::vector<completion_t> tail_expand;
|
||||
completion_list_t tail_expand;
|
||||
expand_cmdsubst(tail_begin, parser, &tail_expand, errors); // TODO: offset error locations
|
||||
|
||||
// Combine the result of the current command substitution with the result of the recursive tail
|
||||
|
@ -761,7 +761,7 @@ void expand_tilde(wcstring &input, const environment_t &vars) {
|
|||
}
|
||||
|
||||
static void unexpand_tildes(const wcstring &input, const environment_t &vars,
|
||||
std::vector<completion_t> *completions) {
|
||||
completion_list_t *completions) {
|
||||
// If input begins with tilde, then try to replace the corresponding string in each completion
|
||||
// with the tilde. If it does not, there's nothing to do.
|
||||
if (input.empty() || input.at(0) != L'~') return;
|
||||
|
@ -865,26 +865,26 @@ class expander_t {
|
|||
/// An expansion stage is a member function pointer.
|
||||
/// It accepts the input string (transferring ownership) and returns the list of output
|
||||
/// completions by reference. It may return an error, which halts expansion.
|
||||
using stage_t = expand_result_t (expander_t::*)(wcstring, std::vector<completion_t> *);
|
||||
using stage_t = expand_result_t (expander_t::*)(wcstring, completion_list_t *);
|
||||
|
||||
expand_result_t stage_cmdsubst(wcstring input, std::vector<completion_t> *out);
|
||||
expand_result_t stage_variables(wcstring input, std::vector<completion_t> *out);
|
||||
expand_result_t stage_braces(wcstring input, std::vector<completion_t> *out);
|
||||
expand_result_t stage_home_and_self(wcstring input, std::vector<completion_t> *out);
|
||||
expand_result_t stage_wildcards(wcstring path_to_expand, std::vector<completion_t> *out);
|
||||
expand_result_t stage_cmdsubst(wcstring input, completion_list_t *out);
|
||||
expand_result_t stage_variables(wcstring input, completion_list_t *out);
|
||||
expand_result_t stage_braces(wcstring input, completion_list_t *out);
|
||||
expand_result_t stage_home_and_self(wcstring input, completion_list_t *out);
|
||||
expand_result_t stage_wildcards(wcstring path_to_expand, completion_list_t *out);
|
||||
|
||||
expander_t(const environment_t &vars, std::shared_ptr<parser_t> parser, expand_flags_t flags,
|
||||
parse_error_list_t *errors)
|
||||
: vars(vars), parser(std::move(parser)), flags(flags), errors(errors) {}
|
||||
|
||||
public:
|
||||
static expand_result_t expand_string(wcstring input, std::vector<completion_t> *out_completions,
|
||||
static expand_result_t expand_string(wcstring input, completion_list_t *out_completions,
|
||||
expand_flags_t flags, const environment_t &vars,
|
||||
const std::shared_ptr<parser_t> &parser,
|
||||
parse_error_list_t *errors);
|
||||
};
|
||||
|
||||
expand_result_t expander_t::stage_cmdsubst(wcstring input, std::vector<completion_t> *out) {
|
||||
expand_result_t expander_t::stage_cmdsubst(wcstring input, completion_list_t *out) {
|
||||
if (flags & expand_flag::skip_cmdsubst) {
|
||||
size_t cur = 0, start = 0, end;
|
||||
switch (parse_util_locate_cmdsubst_range(input, &cur, nullptr, &start, &end, true)) {
|
||||
|
@ -907,7 +907,7 @@ expand_result_t expander_t::stage_cmdsubst(wcstring input, std::vector<completio
|
|||
return expand_result_t::ok;
|
||||
}
|
||||
|
||||
expand_result_t expander_t::stage_variables(wcstring input, std::vector<completion_t> *out) {
|
||||
expand_result_t expander_t::stage_variables(wcstring input, completion_list_t *out) {
|
||||
// We accept incomplete strings here, since complete uses expand_string to expand incomplete
|
||||
// strings from the commandline.
|
||||
wcstring next;
|
||||
|
@ -929,12 +929,12 @@ expand_result_t expander_t::stage_variables(wcstring input, std::vector<completi
|
|||
return expand_result_t::ok;
|
||||
}
|
||||
|
||||
expand_result_t expander_t::stage_braces(wcstring input, std::vector<completion_t> *out) {
|
||||
expand_result_t expander_t::stage_braces(wcstring input, completion_list_t *out) {
|
||||
UNUSED(vars);
|
||||
return expand_braces(input, flags, out, errors);
|
||||
}
|
||||
|
||||
expand_result_t expander_t::stage_home_and_self(wcstring input, std::vector<completion_t> *out) {
|
||||
expand_result_t expander_t::stage_home_and_self(wcstring input, completion_list_t *out) {
|
||||
if (!(flags & expand_flag::skip_home_directories)) {
|
||||
expand_home_directory(input, vars);
|
||||
}
|
||||
|
@ -943,8 +943,7 @@ expand_result_t expander_t::stage_home_and_self(wcstring input, std::vector<comp
|
|||
return expand_result_t::ok;
|
||||
}
|
||||
|
||||
expand_result_t expander_t::stage_wildcards(wcstring path_to_expand,
|
||||
std::vector<completion_t> *out) {
|
||||
expand_result_t expander_t::stage_wildcards(wcstring path_to_expand, completion_list_t *out) {
|
||||
expand_result_t result = expand_result_t::ok;
|
||||
|
||||
remove_internal_separator(&path_to_expand, flags & expand_flag::skip_wildcards);
|
||||
|
@ -1008,7 +1007,7 @@ expand_result_t expander_t::stage_wildcards(wcstring path_to_expand,
|
|||
}
|
||||
|
||||
result = expand_result_t::wildcard_no_match;
|
||||
std::vector<completion_t> expanded;
|
||||
completion_list_t expanded;
|
||||
for (const auto &effective_working_dir : effective_working_dirs) {
|
||||
wildcard_expand_result_t expand_res =
|
||||
wildcard_expand_string(path_to_expand, effective_working_dir, flags, &expanded);
|
||||
|
@ -1038,8 +1037,7 @@ expand_result_t expander_t::stage_wildcards(wcstring path_to_expand,
|
|||
return result;
|
||||
}
|
||||
|
||||
expand_result_t expander_t::expand_string(wcstring input,
|
||||
std::vector<completion_t> *out_completions,
|
||||
expand_result_t expander_t::expand_string(wcstring input, completion_list_t *out_completions,
|
||||
expand_flags_t flags, const environment_t &vars,
|
||||
const std::shared_ptr<parser_t> &parser,
|
||||
parse_error_list_t *errors) {
|
||||
|
@ -1059,7 +1057,7 @@ expand_result_t expander_t::expand_string(wcstring input,
|
|||
&expander_t::stage_wildcards};
|
||||
|
||||
// Load up our single initial completion.
|
||||
std::vector<completion_t> completions, output_storage;
|
||||
completion_list_t completions, output_storage;
|
||||
append_completion(&completions, input);
|
||||
|
||||
expand_result_t total_result = expand_result_t::ok;
|
||||
|
@ -1099,7 +1097,7 @@ expand_result_t expander_t::expand_string(wcstring input,
|
|||
}
|
||||
} // namespace
|
||||
|
||||
expand_result_t expand_string(wcstring input, std::vector<completion_t> *out_completions,
|
||||
expand_result_t expand_string(wcstring input, completion_list_t *out_completions,
|
||||
expand_flags_t flags, const environment_t &vars,
|
||||
const shared_ptr<parser_t> &parser, parse_error_list_t *errors) {
|
||||
return expander_t::expand_string(std::move(input), out_completions, flags, vars, parser,
|
||||
|
@ -1108,7 +1106,7 @@ expand_result_t expand_string(wcstring input, std::vector<completion_t> *out_com
|
|||
|
||||
bool expand_one(wcstring &string, expand_flags_t flags, const environment_t &vars,
|
||||
const shared_ptr<parser_t> &parser, parse_error_list_t *errors) {
|
||||
std::vector<completion_t> completions;
|
||||
completion_list_t completions;
|
||||
|
||||
if (!flags.get(expand_flag::for_completions) && expand_is_clean(string)) {
|
||||
return true;
|
||||
|
@ -1132,7 +1130,7 @@ expand_result_t expand_to_command_and_args(const wcstring &instr, const environm
|
|||
return expand_result_t::ok;
|
||||
}
|
||||
|
||||
std::vector<completion_t> completions;
|
||||
completion_list_t completions;
|
||||
expand_result_t expand_err = expand_string(
|
||||
instr, &completions,
|
||||
{expand_flag::skip_cmdsubst, expand_flag::no_descriptions, expand_flag::skip_jobs}, vars,
|
||||
|
|
|
@ -69,6 +69,7 @@ struct enum_info_t<expand_flag> {
|
|||
using expand_flags_t = enum_set_t<expand_flag>;
|
||||
|
||||
class completion_t;
|
||||
using completion_list_t = std::vector<completion_t>;
|
||||
|
||||
enum : wchar_t {
|
||||
/// Character representing a home directory.
|
||||
|
@ -132,7 +133,7 @@ enum class expand_result_t {
|
|||
/// wildcard_no_match and wildcard_match are normal exit conditions used only on
|
||||
/// strings containing wildcards to tell if the wildcard produced any matches.
|
||||
class parser_t;
|
||||
__warn_unused expand_result_t expand_string(wcstring input, std::vector<completion_t> *output,
|
||||
__warn_unused expand_result_t expand_string(wcstring input, completion_list_t *output,
|
||||
expand_flags_t flags, const environment_t &vars,
|
||||
const std::shared_ptr<parser_t> &parser,
|
||||
parse_error_list_t *errors);
|
||||
|
|
|
@ -1639,7 +1639,7 @@ struct pwd_environment_t : public environment_t {
|
|||
/// After the zero terminator comes one more arg, a string, which is the error
|
||||
/// message to print if the test fails.
|
||||
static bool expand_test(const wchar_t *in, expand_flags_t flags, ...) {
|
||||
std::vector<completion_t> output;
|
||||
completion_list_t output;
|
||||
va_list va;
|
||||
bool res = true;
|
||||
wchar_t *arg;
|
||||
|
@ -1665,7 +1665,7 @@ static bool expand_test(const wchar_t *in, expand_flags_t flags, ...) {
|
|||
va_end(va);
|
||||
|
||||
std::set<wcstring> remaining(expected.begin(), expected.end());
|
||||
std::vector<completion_t>::const_iterator out_it = output.begin(), out_end = output.end();
|
||||
completion_list_t::const_iterator out_it = output.begin(), out_end = output.end();
|
||||
for (; out_it != out_end; ++out_it) {
|
||||
if (!remaining.erase(out_it->completion)) {
|
||||
res = false;
|
||||
|
@ -1690,7 +1690,7 @@ static bool expand_test(const wchar_t *in, expand_flags_t flags, ...) {
|
|||
}
|
||||
msg += L"], found [";
|
||||
first = true;
|
||||
for (std::vector<completion_t>::const_iterator it = output.begin(), end = output.end();
|
||||
for (completion_list_t::const_iterator it = output.begin(), end = output.end();
|
||||
it != end; ++it) {
|
||||
if (!first) msg += L", ";
|
||||
first = false;
|
||||
|
@ -2898,7 +2898,7 @@ static void test_completion_insertions() {
|
|||
|
||||
static void perform_one_autosuggestion_cd_test(const wcstring &command, const wcstring &expected,
|
||||
const environment_t &vars, long line) {
|
||||
std::vector<completion_t> comps;
|
||||
completion_list_t comps;
|
||||
complete(command, &comps, completion_request_t::autosuggestion, vars, nullptr);
|
||||
|
||||
bool expects_error = (expected == L"<error>");
|
||||
|
@ -2934,7 +2934,7 @@ static void perform_one_autosuggestion_cd_test(const wcstring &command, const wc
|
|||
|
||||
static void perform_one_completion_cd_test(const wcstring &command, const wcstring &expected,
|
||||
const environment_t &vars, long line) {
|
||||
std::vector<completion_t> comps;
|
||||
completion_list_t comps;
|
||||
complete(command, &comps, {}, vars, nullptr);
|
||||
|
||||
bool expects_error = (expected == L"<error>");
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "wutil.h" // IWYU pragma: keep
|
||||
|
||||
using comp_t = pager_t::comp_t;
|
||||
using completion_list_t = std::vector<completion_t>;
|
||||
using completion_list_t = completion_list_t;
|
||||
using comp_info_list_t = std::vector<comp_t>;
|
||||
|
||||
/// The minimum width (in characters) the terminal must to show completions at all.
|
||||
|
|
|
@ -60,8 +60,6 @@ enum class selection_motion_t {
|
|||
// How many rows we will show in the "initial" pager.
|
||||
#define PAGER_UNDISCLOSED_MAX_ROWS 4
|
||||
|
||||
typedef std::vector<completion_t> completion_list_t;
|
||||
|
||||
class pager_t {
|
||||
size_t available_term_width;
|
||||
size_t available_term_height;
|
||||
|
|
|
@ -456,7 +456,7 @@ eval_result_t parse_execution_context_t::run_switch_statement(
|
|||
const wcstring switch_value = get_source(switch_value_n);
|
||||
|
||||
// Expand it. We need to offset any errors by the position of the string.
|
||||
std::vector<completion_t> switch_values_expanded;
|
||||
completion_list_t switch_values_expanded;
|
||||
parse_error_list_t errors;
|
||||
auto expand_ret =
|
||||
expand_string(switch_value, &switch_values_expanded, expand_flag::no_descriptions,
|
||||
|
@ -868,7 +868,7 @@ eval_result_t parse_execution_context_t::expand_arguments_from_nodes(
|
|||
// Get all argument nodes underneath the statement. We guess we'll have that many arguments (but
|
||||
// may have more or fewer, if there are wildcards involved).
|
||||
out_arguments->reserve(out_arguments->size() + argument_nodes.size());
|
||||
std::vector<completion_t> arg_expanded;
|
||||
completion_list_t arg_expanded;
|
||||
for (const auto &arg_node : argument_nodes) {
|
||||
// Expect all arguments to have source.
|
||||
assert(arg_node.has_source());
|
||||
|
@ -1023,7 +1023,7 @@ eval_result_t parse_execution_context_t::apply_variable_assignments(
|
|||
assert(equals_pos);
|
||||
const wcstring &variable_name = source.substr(0, *equals_pos);
|
||||
const wcstring expression = source.substr(*equals_pos + 1);
|
||||
std::vector<completion_t> expression_expanded;
|
||||
completion_list_t expression_expanded;
|
||||
parse_error_list_t errors;
|
||||
// TODO this is mostly copied from expand_arguments_from_nodes, maybe extract to function
|
||||
auto expand_ret =
|
||||
|
|
|
@ -305,10 +305,9 @@ void parser_t::emit_profiling(const char *path) const {
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<completion_t> parser_t::expand_argument_list(const wcstring &arg_list_src,
|
||||
expand_flags_t eflags,
|
||||
const environment_t &vars,
|
||||
const std::shared_ptr<parser_t> &parser) {
|
||||
completion_list_t parser_t::expand_argument_list(const wcstring &arg_list_src,
|
||||
expand_flags_t eflags, const environment_t &vars,
|
||||
const std::shared_ptr<parser_t> &parser) {
|
||||
// Parse the string as an argument list.
|
||||
parse_node_tree_t tree;
|
||||
if (!parse_tree_from_string(arg_list_src, parse_flag_none, &tree, nullptr /* errors */,
|
||||
|
@ -318,7 +317,7 @@ std::vector<completion_t> parser_t::expand_argument_list(const wcstring &arg_lis
|
|||
}
|
||||
|
||||
// Get the root argument list and extract arguments from it.
|
||||
std::vector<completion_t> result;
|
||||
completion_list_t result;
|
||||
assert(!tree.empty());
|
||||
tnode_t<grammar::freestanding_argument_list> arg_list(&tree, &tree.at(0));
|
||||
while (auto arg = arg_list.next_in_list<grammar::argument>()) {
|
||||
|
|
|
@ -279,10 +279,9 @@ class parser_t : public std::enable_shared_from_this<parser_t> {
|
|||
/// Evaluate line as a list of parameters, i.e. tokenize it and perform parameter expansion and
|
||||
/// cmdsubst execution on the tokens. Errors are ignored. If a parser is provided, it is used
|
||||
/// for command substitution expansion.
|
||||
static std::vector<completion_t> expand_argument_list(const wcstring &arg_list_src,
|
||||
expand_flags_t flags,
|
||||
const environment_t &vars,
|
||||
const std::shared_ptr<parser_t> &parser);
|
||||
static completion_list_t expand_argument_list(const wcstring &arg_list_src,
|
||||
expand_flags_t flags, const environment_t &vars,
|
||||
const std::shared_ptr<parser_t> &parser);
|
||||
|
||||
/// Returns a string describing the current parser position in the format 'FILENAME (line
|
||||
/// LINE_NUMBER): LINE'. Example:
|
||||
|
|
|
@ -478,8 +478,8 @@ class reader_data_t : public std::enable_shared_from_this<reader_data_t> {
|
|||
bool jump(jump_direction_t dir, jump_precision_t precision, editable_line_t *el,
|
||||
wchar_t target);
|
||||
|
||||
bool handle_completions(const std::vector<completion_t> &comp, size_t token_begin,
|
||||
size_t token_end, bool cont_after_prefix_insertion);
|
||||
bool handle_completions(const completion_list_t &comp, size_t token_begin, size_t token_end,
|
||||
bool cont_after_prefix_insertion);
|
||||
|
||||
void sanity_check() const;
|
||||
void set_command_line_and_position(editable_line_t *el, const wcstring &new_str, size_t pos);
|
||||
|
@ -1325,7 +1325,7 @@ static std::function<autosuggestion_result_t(void)> get_autosuggestion_performer
|
|||
|
||||
// Try normal completions.
|
||||
completion_request_flags_t complete_flags = completion_request_t::autosuggestion;
|
||||
std::vector<completion_t> completions;
|
||||
completion_list_t completions;
|
||||
complete(search_string, &completions, complete_flags, *vars, nullptr);
|
||||
completions_sort_and_prioritize(&completions, complete_flags);
|
||||
if (!completions.empty()) {
|
||||
|
@ -1466,7 +1466,7 @@ static bool reader_can_replace(const wcstring &in, int flags) {
|
|||
}
|
||||
|
||||
/// Determine the best match type for a set of completions.
|
||||
static fuzzy_match_type_t get_best_match_type(const std::vector<completion_t> &comp) {
|
||||
static fuzzy_match_type_t get_best_match_type(const completion_list_t &comp) {
|
||||
fuzzy_match_type_t best_type = fuzzy_match_none;
|
||||
for (const auto &i : comp) {
|
||||
best_type = std::min(best_type, i.match.type);
|
||||
|
@ -1497,7 +1497,7 @@ static fuzzy_match_type_t get_best_match_type(const std::vector<completion_t> &c
|
|||
/// completions after inserting it.
|
||||
///
|
||||
/// Return true if we inserted text into the command line, false if we did not.
|
||||
bool reader_data_t::handle_completions(const std::vector<completion_t> &comp, size_t token_begin,
|
||||
bool reader_data_t::handle_completions(const completion_list_t &comp, size_t token_begin,
|
||||
size_t token_end, bool cont_after_prefix_insertion) {
|
||||
bool done = false;
|
||||
bool success = false;
|
||||
|
@ -1543,7 +1543,7 @@ bool reader_data_t::handle_completions(const std::vector<completion_t> &comp, si
|
|||
|
||||
// Decide which completions survived. There may be a lot of them; it would be nice if we could
|
||||
// figure out how to avoid copying them here.
|
||||
std::vector<completion_t> surviving_completions;
|
||||
completion_list_t surviving_completions;
|
||||
for (const completion_t &el : comp) {
|
||||
// Ignore completions with a less suitable match type than the best.
|
||||
if (el.match.type > best_match_type) continue;
|
||||
|
@ -2381,7 +2381,7 @@ struct readline_loop_state_t {
|
|||
bool comp_empty{true};
|
||||
|
||||
/// List of completions.
|
||||
std::vector<completion_t> comp;
|
||||
completion_list_t comp;
|
||||
|
||||
/// Whether we are skipping redundant repaints.
|
||||
bool coalescing_repaints = false;
|
||||
|
|
|
@ -147,7 +147,7 @@ void reader_push(parser_t &parser, const wcstring &name);
|
|||
void reader_pop();
|
||||
|
||||
/// Specify function to use for finding possible tab completions.
|
||||
typedef void (*complete_function_t)(const wcstring &, std::vector<completion_t> *,
|
||||
typedef void (*complete_function_t)(const wcstring &, completion_list_t *,
|
||||
completion_request_flags_t, const environment_t &,
|
||||
const std::shared_ptr<parser_t> &parser);
|
||||
void reader_set_complete_function(complete_function_t);
|
||||
|
|
|
@ -184,7 +184,7 @@ struct wc_complete_pack_t {
|
|||
};
|
||||
|
||||
// Weirdly specific and non-reusable helper function that makes its one call site much clearer.
|
||||
static bool has_prefix_match(const std::vector<completion_t> *comps, size_t first) {
|
||||
static bool has_prefix_match(const completion_list_t *comps, size_t first) {
|
||||
if (comps != nullptr) {
|
||||
const size_t after_count = comps->size();
|
||||
for (size_t j = first; j < after_count; j++) {
|
||||
|
@ -203,7 +203,7 @@ static bool has_prefix_match(const std::vector<completion_t> *comps, size_t firs
|
|||
/// wildcards. This is historic behavior.
|
||||
static bool wildcard_complete_internal(const wchar_t *str, const wchar_t *wc,
|
||||
const wc_complete_pack_t ¶ms, complete_flags_t flags,
|
||||
std::vector<completion_t> *out, bool is_first_call = false) {
|
||||
completion_list_t *out, bool is_first_call = false) {
|
||||
assert(str != nullptr);
|
||||
assert(wc != nullptr);
|
||||
|
||||
|
@ -315,7 +315,7 @@ static bool wildcard_complete_internal(const wchar_t *str, const wchar_t *wc,
|
|||
|
||||
bool wildcard_complete(const wcstring &str, const wchar_t *wc,
|
||||
const std::function<wcstring(const wcstring &)> &desc_func,
|
||||
std::vector<completion_t> *out, expand_flags_t expand_flags,
|
||||
completion_list_t *out, expand_flags_t expand_flags,
|
||||
complete_flags_t flags) {
|
||||
// Note out may be NULL.
|
||||
assert(wc != nullptr);
|
||||
|
@ -390,7 +390,7 @@ static const wchar_t *file_get_desc(const wcstring &filename, int lstat_res,
|
|||
/// up. Note that the filename came from a readdir() call, so we know it exists.
|
||||
static bool wildcard_test_flags_then_complete(const wcstring &filepath, const wcstring &filename,
|
||||
const wchar_t *wc, expand_flags_t expand_flags,
|
||||
std::vector<completion_t> *out) {
|
||||
completion_list_t *out) {
|
||||
// Check if it will match before stat().
|
||||
if (!wildcard_complete(filename, wc, {}, nullptr, expand_flags, 0)) {
|
||||
return false;
|
||||
|
@ -465,7 +465,7 @@ class wildcard_expander_t {
|
|||
// Flags controlling expansion.
|
||||
const expand_flags_t flags;
|
||||
// Resolved items get inserted into here. This is transient of course.
|
||||
std::vector<completion_t> *resolved_completions;
|
||||
completion_list_t *resolved_completions;
|
||||
// Whether we have been interrupted.
|
||||
bool did_interrupt{false};
|
||||
// Whether we have successfully added any completions.
|
||||
|
@ -629,7 +629,7 @@ class wildcard_expander_t {
|
|||
}
|
||||
|
||||
public:
|
||||
wildcard_expander_t(wcstring wd, expand_flags_t f, std::vector<completion_t> *r)
|
||||
wildcard_expander_t(wcstring wd, expand_flags_t f, completion_list_t *r)
|
||||
: working_directory(std::move(wd)), flags(f), resolved_completions(r) {
|
||||
assert(resolved_completions != nullptr);
|
||||
|
||||
|
@ -897,8 +897,7 @@ void wildcard_expander_t::expand(const wcstring &base_dir, const wchar_t *wc,
|
|||
|
||||
wildcard_expand_result_t wildcard_expand_string(const wcstring &wc,
|
||||
const wcstring &working_directory,
|
||||
expand_flags_t flags,
|
||||
std::vector<completion_t> *output) {
|
||||
expand_flags_t flags, completion_list_t *output) {
|
||||
assert(output != nullptr);
|
||||
// Fuzzy matching only if we're doing completions.
|
||||
assert(flags.get(expand_flag::for_completions) || !flags.get(expand_flag::fuzzy_match));
|
||||
|
|
|
@ -48,8 +48,7 @@ enum class wildcard_expand_result_t {
|
|||
};
|
||||
wildcard_expand_result_t wildcard_expand_string(const wcstring &wc,
|
||||
const wcstring &working_directory,
|
||||
expand_flags_t flags,
|
||||
std::vector<completion_t> *out);
|
||||
expand_flags_t flags, completion_list_t *out);
|
||||
|
||||
/// Test whether the given wildcard matches the string. Does not perform any I/O.
|
||||
///
|
||||
|
@ -68,7 +67,6 @@ bool wildcard_has(const wchar_t *, bool internal);
|
|||
|
||||
/// Test wildcard completion.
|
||||
bool wildcard_complete(const wcstring &str, const wchar_t *wc, const description_func_t &desc_func,
|
||||
std::vector<completion_t> *out, expand_flags_t expand_flags,
|
||||
complete_flags_t flags);
|
||||
completion_list_t *out, expand_flags_t expand_flags, complete_flags_t flags);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue