mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-04 07:21:14 -03:00
Merge branch 'master' into ast
Conflicts: complete.cpp fish_tests.cpp highlight.cpp
This commit is contained in:
40
complete.cpp
40
complete.cpp
@@ -45,6 +45,7 @@
|
||||
#include "wutil.h"
|
||||
#include "path.h"
|
||||
#include "parse_tree.h"
|
||||
#include "iothread.h"
|
||||
|
||||
/*
|
||||
Completion description strings, mostly for different types of files, such as sockets, block devices, etc.
|
||||
@@ -342,7 +343,6 @@ class completer_t
|
||||
const completion_request_flags_t flags;
|
||||
const wcstring initial_cmd;
|
||||
std::vector<completion_t> completions;
|
||||
wcstring_list_t commands_to_load;
|
||||
|
||||
/** Table of completions conditions that have already been tested and the corresponding test results */
|
||||
typedef std::map<wcstring, bool> condition_cache_t;
|
||||
@@ -431,7 +431,7 @@ public:
|
||||
/* Never do command substitution in autosuggestions. Sadly, we also can't yet do job expansion because it's not thread safe. */
|
||||
expand_flags_t result = 0;
|
||||
if (this->type() == COMPLETE_AUTOSUGGEST)
|
||||
result |= EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_JOBS;
|
||||
result |= EXPAND_SKIP_CMDSUBST;
|
||||
|
||||
/* Allow fuzzy matching */
|
||||
if (this->fuzzy())
|
||||
@@ -439,18 +439,6 @@ public:
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void get_commands_to_load(wcstring_list_t *lst)
|
||||
{
|
||||
if (lst)
|
||||
lst->insert(lst->end(), commands_to_load.begin(), commands_to_load.end());
|
||||
}
|
||||
|
||||
bool has_commands_to_load() const
|
||||
{
|
||||
return ! commands_to_load.empty();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/* Autoloader for completions */
|
||||
@@ -1351,6 +1339,15 @@ void complete_load(const wcstring &name, bool reload)
|
||||
completion_autoloader.load(name, reload);
|
||||
}
|
||||
|
||||
// Performed on main thread, from background thread. Return type is ignored.
|
||||
static int complete_load_no_reload(wcstring *name)
|
||||
{
|
||||
assert(name != NULL);
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
complete_load(*name, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Find completion for the argument str of command cmd_orig with
|
||||
previous option popt. Insert results into comp_out. Return 0 if file
|
||||
@@ -1375,14 +1372,15 @@ bool completer_t::complete_param(const wcstring &scmd_orig, const wcstring &spop
|
||||
|
||||
if (this->type() == COMPLETE_DEFAULT)
|
||||
{
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
complete_load(cmd, true);
|
||||
}
|
||||
else if (this->type() == COMPLETE_AUTOSUGGEST)
|
||||
{
|
||||
/* Maybe indicate we should try loading this on the main thread */
|
||||
if (! list_contains_string(this->commands_to_load, cmd) && ! completion_autoloader.has_tried_loading(cmd))
|
||||
/* Maybe load this command (on the main thread) */
|
||||
if (! completion_autoloader.has_tried_loading(cmd))
|
||||
{
|
||||
this->commands_to_load.push_back(cmd);
|
||||
iothread_perform_on_main(complete_load_no_reload, &cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1793,7 +1791,7 @@ bool completer_t::try_complete_user(const wcstring &str)
|
||||
return res;
|
||||
}
|
||||
|
||||
void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> &comps, completion_request_flags_t flags, wcstring_list_t *commands_to_load)
|
||||
void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> &comps, completion_request_flags_t flags)
|
||||
{
|
||||
/* Determine the innermost subcommand */
|
||||
const wchar_t *cmdsubst_begin, *cmdsubst_end;
|
||||
@@ -1932,11 +1930,6 @@ void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> &comps
|
||||
if (completer.empty())
|
||||
do_file = true;
|
||||
|
||||
/* But if we are planning on loading commands, don't do file completions.
|
||||
See https://github.com/fish-shell/fish-shell/issues/378 */
|
||||
if (commands_to_load != NULL && completer.has_commands_to_load())
|
||||
do_file = false;
|
||||
|
||||
/* And if we're autosuggesting, and the token is empty, don't do file suggestions */
|
||||
if ((flags & COMPLETION_REQUEST_AUTOSUGGESTION) && current_argument_unescape.empty())
|
||||
do_file = false;
|
||||
@@ -1948,7 +1941,6 @@ void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> &comps
|
||||
}
|
||||
|
||||
comps = completer.get_completions();
|
||||
completer.get_commands_to_load(commands_to_load);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user