mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 21:18:53 +00:00
Migrate builtin_complete recursion_level into parser_t::libdata
This commit is contained in:
parent
2ce827343e
commit
0de1611bf1
2 changed files with 6 additions and 4 deletions
|
@ -110,7 +110,6 @@ static void builtin_complete_remove(const wcstring_list_t &cmds, const wcstring_
|
||||||
// complete.cpp for any heavy lifting.
|
// complete.cpp for any heavy lifting.
|
||||||
int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||||
ASSERT_IS_MAIN_THREAD();
|
ASSERT_IS_MAIN_THREAD();
|
||||||
static int recursion_level = 0;
|
|
||||||
|
|
||||||
wchar_t *cmd = argv[0];
|
wchar_t *cmd = argv[0];
|
||||||
int argc = builtin_count_args(argv);
|
int argc = builtin_count_args(argv);
|
||||||
|
@ -325,8 +324,8 @@ int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||||
// argument, not the reader buffer.
|
// argument, not the reader buffer.
|
||||||
builtin_commandline_scoped_transient_t temp_buffer(do_complete_param);
|
builtin_commandline_scoped_transient_t temp_buffer(do_complete_param);
|
||||||
|
|
||||||
if (recursion_level < 1) {
|
if (parser.libdata().builtin_complete_recursion_level < 1) {
|
||||||
recursion_level++;
|
parser.libdata().builtin_complete_recursion_level++;
|
||||||
|
|
||||||
std::vector<completion_t> comp;
|
std::vector<completion_t> comp;
|
||||||
complete(do_complete_param, &comp, completion_request_t::fuzzy_match, parser.vars(),
|
complete(do_complete_param, &comp, completion_request_t::fuzzy_match, parser.vars(),
|
||||||
|
@ -364,7 +363,7 @@ int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||||
streams.out.push_back(L'\n');
|
streams.out.push_back(L'\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
recursion_level--;
|
parser.libdata().builtin_complete_recursion_level--;
|
||||||
}
|
}
|
||||||
} else if (cmd_to_complete.empty() && path.empty()) {
|
} else if (cmd_to_complete.empty() && path.empty()) {
|
||||||
// No arguments specified, meaning we print the definitions of all specified completions
|
// No arguments specified, meaning we print the definitions of all specified completions
|
||||||
|
|
|
@ -151,6 +151,9 @@ class completion_t;
|
||||||
struct library_data_t {
|
struct library_data_t {
|
||||||
/// A counter incremented every time a command executes.
|
/// A counter incremented every time a command executes.
|
||||||
uint64_t exec_count{0};
|
uint64_t exec_count{0};
|
||||||
|
|
||||||
|
/// Number of recursive calls to builtin_complete().
|
||||||
|
uint32_t builtin_complete_recursion_level{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
class parser_t : public std::enable_shared_from_this<parser_t> {
|
class parser_t : public std::enable_shared_from_this<parser_t> {
|
||||||
|
|
Loading…
Reference in a new issue