mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 23:24:39 +00:00
Remove unused vars identified by lint
This commit is contained in:
parent
f872f25f5b
commit
55b2d36028
6 changed files with 81 additions and 100 deletions
|
@ -318,8 +318,7 @@ int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
recursion_level++;
|
||||
|
||||
std::vector<completion_t> comp;
|
||||
complete(do_complete_param, &comp, COMPLETION_REQUEST_DEFAULT,
|
||||
env_vars_snapshot_t::current());
|
||||
complete(do_complete_param, &comp, COMPLETION_REQUEST_DEFAULT);
|
||||
|
||||
for (size_t i = 0; i < comp.size(); i++) {
|
||||
const completion_t &next = comp.at(i);
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "builtin.h"
|
||||
#include "common.h"
|
||||
#include "complete.h"
|
||||
#include "env.h"
|
||||
#include "exec.h"
|
||||
#include "expand.h"
|
||||
#include "fallback.h" // IWYU pragma: keep
|
||||
|
@ -290,7 +289,6 @@ class completer_t {
|
|||
const completion_request_flags_t flags;
|
||||
const wcstring initial_cmd;
|
||||
std::vector<completion_t> completions;
|
||||
const env_vars_snapshot_t &vars; // transient, stack-allocated
|
||||
|
||||
/// Table of completions conditions that have already been tested and the corresponding test
|
||||
/// results.
|
||||
|
@ -316,8 +314,7 @@ class completer_t {
|
|||
}
|
||||
|
||||
public:
|
||||
completer_t(const wcstring &c, completion_request_flags_t f, const env_vars_snapshot_t &evs)
|
||||
: flags(f), initial_cmd(c), vars(evs) {}
|
||||
completer_t(const wcstring &c, completion_request_flags_t f) : flags(f), initial_cmd(c) {}
|
||||
|
||||
bool empty() const { return completions.empty(); }
|
||||
const std::vector<completion_t> &get_completions(void) { return completions; }
|
||||
|
@ -1238,7 +1235,7 @@ bool completer_t::try_complete_user(const wcstring &str) {
|
|||
}
|
||||
|
||||
void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> *out_comps,
|
||||
completion_request_flags_t flags, const env_vars_snapshot_t &vars) {
|
||||
completion_request_flags_t flags) {
|
||||
// Determine the innermost subcommand.
|
||||
const wchar_t *cmdsubst_begin, *cmdsubst_end;
|
||||
parse_util_cmdsubst_extent(cmd_with_subcmds.c_str(), cmd_with_subcmds.size(), &cmdsubst_begin,
|
||||
|
@ -1247,7 +1244,7 @@ void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> *out_c
|
|||
const wcstring cmd = wcstring(cmdsubst_begin, cmdsubst_end - cmdsubst_begin);
|
||||
|
||||
// Make our completer.
|
||||
completer_t completer(cmd, flags, vars);
|
||||
completer_t completer(cmd, flags);
|
||||
|
||||
wcstring current_command;
|
||||
const size_t pos = cmd.size();
|
||||
|
|
|
@ -157,9 +157,8 @@ void complete_remove(const wcstring &cmd, bool cmd_is_path, const wcstring &opti
|
|||
void complete_remove_all(const wcstring &cmd, bool cmd_is_path);
|
||||
|
||||
/// Find all completions of the command cmd, insert them into out.
|
||||
class env_vars_snapshot_t;
|
||||
void complete(const wcstring &cmd, std::vector<completion_t> *out_comps,
|
||||
completion_request_flags_t flags, const env_vars_snapshot_t &vars);
|
||||
completion_request_flags_t flags);
|
||||
|
||||
/// Return a list of all current completions.
|
||||
wcstring complete_print();
|
||||
|
|
|
@ -2092,9 +2092,8 @@ static void test_complete(void) {
|
|||
const wcstring_list_t names(name_strs, name_strs + count);
|
||||
std::vector<completion_t> completions;
|
||||
complete_set_variable_names(&names);
|
||||
const env_vars_snapshot_t &vars = env_vars_snapshot_t::current();
|
||||
|
||||
complete(L"$", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"$", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
completions_sort_and_prioritize(&completions);
|
||||
do_test(completions.size() == 6);
|
||||
do_test(completions.at(0).completion == L"Bar1");
|
||||
|
@ -2105,7 +2104,7 @@ static void test_complete(void) {
|
|||
do_test(completions.at(5).completion == L"Foo3");
|
||||
|
||||
completions.clear();
|
||||
complete(L"$F", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"$F", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
completions_sort_and_prioritize(&completions);
|
||||
do_test(completions.size() == 3);
|
||||
do_test(completions.at(0).completion == L"oo1");
|
||||
|
@ -2113,13 +2112,12 @@ static void test_complete(void) {
|
|||
do_test(completions.at(2).completion == L"oo3");
|
||||
|
||||
completions.clear();
|
||||
complete(L"$1", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"$1", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
completions_sort_and_prioritize(&completions);
|
||||
do_test(completions.empty());
|
||||
|
||||
completions.clear();
|
||||
complete(L"$1", &completions, COMPLETION_REQUEST_DEFAULT | COMPLETION_REQUEST_FUZZY_MATCH,
|
||||
vars);
|
||||
complete(L"$1", &completions, COMPLETION_REQUEST_DEFAULT | COMPLETION_REQUEST_FUZZY_MATCH);
|
||||
completions_sort_and_prioritize(&completions);
|
||||
do_test(completions.size() == 2);
|
||||
do_test(completions.at(0).completion == L"$Bar1");
|
||||
|
@ -2131,25 +2129,24 @@ static void test_complete(void) {
|
|||
if (system("chmod 700 'test/complete_test/testfile'")) err(L"chmod failed");
|
||||
|
||||
completions.clear();
|
||||
complete(L"echo (test/complete_test/testfil", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo (test/complete_test/testfil", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"e");
|
||||
|
||||
completions.clear();
|
||||
complete(L"echo (ls test/complete_test/testfil", &completions, COMPLETION_REQUEST_DEFAULT,
|
||||
vars);
|
||||
complete(L"echo (ls test/complete_test/testfil", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"e");
|
||||
|
||||
completions.clear();
|
||||
complete(L"echo (command ls test/complete_test/testfil", &completions,
|
||||
COMPLETION_REQUEST_DEFAULT, vars);
|
||||
COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"e");
|
||||
|
||||
// Completing after spaces - see #2447
|
||||
completions.clear();
|
||||
complete(L"echo (ls test/complete_test/has\\ ", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo (ls test/complete_test/has\\ ", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"space");
|
||||
|
||||
|
@ -2161,91 +2158,91 @@ static void test_complete(void) {
|
|||
|
||||
// Complete a function name.
|
||||
completions.clear();
|
||||
complete(L"echo (scuttlebut", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo (scuttlebut", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"t");
|
||||
|
||||
// But not with the command prefix.
|
||||
completions.clear();
|
||||
complete(L"echo (command scuttlebut", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo (command scuttlebut", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 0);
|
||||
|
||||
// Not with the builtin prefix.
|
||||
completions.clear();
|
||||
complete(L"echo (builtin scuttlebut", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo (builtin scuttlebut", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 0);
|
||||
|
||||
// Not after a redirection.
|
||||
completions.clear();
|
||||
complete(L"echo hi > scuttlebut", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo hi > scuttlebut", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 0);
|
||||
|
||||
// Trailing spaces (#1261).
|
||||
complete_add(L"foobarbaz", false, wcstring(), option_type_args_only, NO_FILES, NULL, L"qux",
|
||||
NULL, COMPLETE_AUTO_SPACE);
|
||||
completions.clear();
|
||||
complete(L"foobarbaz ", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"foobarbaz ", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"qux");
|
||||
|
||||
// Don't complete variable names in single quotes (#1023).
|
||||
completions.clear();
|
||||
complete(L"echo '$Foo", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo '$Foo", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.empty());
|
||||
completions.clear();
|
||||
complete(L"echo \\$Foo", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo \\$Foo", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.empty());
|
||||
|
||||
// File completions.
|
||||
completions.clear();
|
||||
complete(L"cat test/complete_test/te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"cat test/complete_test/te", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
completions.clear();
|
||||
complete(L"echo sup > test/complete_test/te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo sup > test/complete_test/te", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
completions.clear();
|
||||
complete(L"echo sup > test/complete_test/te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo sup > test/complete_test/te", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
|
||||
if (!pushd("test/complete_test")) return;
|
||||
complete(L"cat te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"cat te", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
completions.clear();
|
||||
complete(L"something --abc=te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"something --abc=te", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
completions.clear();
|
||||
complete(L"something -abc=te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"something -abc=te", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
completions.clear();
|
||||
complete(L"something abc=te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"something abc=te", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
completions.clear();
|
||||
complete(L"something abc=stfile", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"something abc=stfile", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.size() == 0);
|
||||
completions.clear();
|
||||
complete(L"something abc=stfile", &completions, COMPLETION_REQUEST_FUZZY_MATCH, vars);
|
||||
complete(L"something abc=stfile", &completions, COMPLETION_REQUEST_FUZZY_MATCH);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"abc=testfile");
|
||||
|
||||
// Zero escapes can cause problems. See issue #1631.
|
||||
completions.clear();
|
||||
complete(L"cat foo\\0", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"cat foo\\0", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.empty());
|
||||
completions.clear();
|
||||
complete(L"cat foo\\0bar", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"cat foo\\0bar", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.empty());
|
||||
completions.clear();
|
||||
complete(L"cat \\0", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"cat \\0", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.empty());
|
||||
completions.clear();
|
||||
complete(L"cat te\\0", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"cat te\\0", &completions, COMPLETION_REQUEST_DEFAULT);
|
||||
do_test(completions.empty());
|
||||
|
||||
popd();
|
||||
|
@ -2317,10 +2314,9 @@ static void test_completion_insertions() {
|
|||
}
|
||||
|
||||
static void perform_one_autosuggestion_cd_test(const wcstring &command,
|
||||
const env_vars_snapshot_t &vars,
|
||||
const wcstring &expected, long line) {
|
||||
std::vector<completion_t> comps;
|
||||
complete(command, &comps, COMPLETION_REQUEST_AUTOSUGGESTION, vars);
|
||||
complete(command, &comps, COMPLETION_REQUEST_AUTOSUGGESTION);
|
||||
|
||||
bool expects_error = (expected == L"<error>");
|
||||
|
||||
|
@ -2387,69 +2383,60 @@ static void test_autosuggest_suggest_special() {
|
|||
const wcstring wd = L"test/autosuggest_test";
|
||||
const env_vars_snapshot_t &vars = env_vars_snapshot_t::current();
|
||||
|
||||
perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/0", vars, L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"test/autosuggest_test/0", vars, L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/0", vars, L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/1", vars, L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"test/autosuggest_test/1", vars, L"foo bar/",
|
||||
__LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/1", vars, L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/2", vars, L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"test/autosuggest_test/2", vars, L"foo bar/",
|
||||
__LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/2", vars, L"foo bar/",
|
||||
__LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/3", vars, L"foo\\bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"test/autosuggest_test/3", vars, L"foo\\bar/",
|
||||
__LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/3", vars, L"foo\\bar/",
|
||||
__LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/4", vars, L"foo'bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"test/autosuggest_test/4", vars, L"foo'bar/",
|
||||
__LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/4", vars, L"foo'bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/5", vars, L"foo\"bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"test/autosuggest_test/5", vars, L"foo\"bar/",
|
||||
__LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/5", vars, L"foo\"bar/",
|
||||
__LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/0", L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"test/autosuggest_test/0", L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/0", L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/1", L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"test/autosuggest_test/1", L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/1", L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/2", L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"test/autosuggest_test/2", L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/2", L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/3", L"foo\\bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"test/autosuggest_test/3", L"foo\\bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/3", L"foo\\bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/4", L"foo'bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"test/autosuggest_test/4", L"foo'bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/4", L"foo'bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/5", L"foo\"bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"test/autosuggest_test/5", L"foo\"bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/5", L"foo\"bar/", __LINE__);
|
||||
|
||||
env_set_one(L"AUTOSUGGEST_TEST_LOC", ENV_LOCAL, wd);
|
||||
perform_one_autosuggestion_cd_test(L"cd $AUTOSUGGEST_TEST_LOC/0", vars, L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd ~/test_autosuggest_suggest_specia", vars, L"l/",
|
||||
perform_one_autosuggestion_cd_test(L"cd $AUTOSUGGEST_TEST_LOC/0", L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd ~/test_autosuggest_suggest_specia", L"l/", __LINE__);
|
||||
|
||||
perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/start/", L"unique2/unique3/",
|
||||
__LINE__);
|
||||
|
||||
perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/start/", vars,
|
||||
L"unique2/unique3/", __LINE__);
|
||||
|
||||
if (!pushd(wcs2string(wd).c_str())) return;
|
||||
perform_one_autosuggestion_cd_test(L"cd 0", vars, L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"0", vars, L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd '0", vars, L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 1", vars, L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"1", vars, L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd '1", vars, L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 2", vars, L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"2", vars, L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd '2", vars, L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 3", vars, L"foo\\bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"3", vars, L"foo\\bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd '3", vars, L"foo\\bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 4", vars, L"foo'bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"4", vars, L"foo'bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd '4", vars, L"foo'bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 5", vars, L"foo\"bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"5", vars, L"foo\"bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd '5", vars, L"foo\"bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 0", L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"0", L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd '0", L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 1", L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"1", L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd '1", L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 2", L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"2", L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd '2", L"foo bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 3", L"foo\\bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"3", L"foo\\bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd '3", L"foo\\bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 4", L"foo'bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"4", L"foo'bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd '4", L"foo'bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd 5", L"foo\"bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd \"5", L"foo\"bar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd '5", L"foo\"bar/", __LINE__);
|
||||
|
||||
// A single quote should defeat tilde expansion.
|
||||
perform_one_autosuggestion_cd_test(L"cd '~/test_autosuggest_suggest_specia'", vars, L"<error>",
|
||||
perform_one_autosuggestion_cd_test(L"cd '~/test_autosuggest_suggest_specia'", L"<error>",
|
||||
__LINE__);
|
||||
|
||||
// Don't crash on ~ (issue #2696). Note this is cwd dependent.
|
||||
if (system("mkdir -p '~hahaha/path1/path2/'")) err(L"mkdir failed");
|
||||
perform_one_autosuggestion_cd_test(L"cd ~haha", vars, L"ha/path1/path2/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd ~hahaha/", vars, L"path1/path2/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd ~haha", L"ha/path1/path2/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd ~hahaha/", L"path1/path2/", __LINE__);
|
||||
|
||||
popd();
|
||||
system("rmdir ~/test_autosuggest_suggest_special/");
|
||||
|
@ -2457,7 +2444,7 @@ static void test_autosuggest_suggest_special() {
|
|||
|
||||
static void perform_one_autosuggestion_should_ignore_test(const wcstring &command, long line) {
|
||||
completion_list_t comps;
|
||||
complete(command, &comps, COMPLETION_REQUEST_AUTOSUGGESTION, env_vars_snapshot_t::current());
|
||||
complete(command, &comps, COMPLETION_REQUEST_AUTOSUGGESTION);
|
||||
do_test(comps.empty());
|
||||
if (!comps.empty()) {
|
||||
const wcstring &suggestion = comps.front().completion;
|
||||
|
|
|
@ -1188,7 +1188,7 @@ static std::function<autosuggestion_result_t(void)> get_autosuggestion_performer
|
|||
|
||||
// Try normal completions.
|
||||
std::vector<completion_t> completions;
|
||||
complete(search_string, &completions, COMPLETION_REQUEST_AUTOSUGGESTION, vars);
|
||||
complete(search_string, &completions, COMPLETION_REQUEST_AUTOSUGGESTION);
|
||||
completions_sort_and_prioritize(&completions);
|
||||
if (!completions.empty()) {
|
||||
const completion_t &comp = completions.at(0);
|
||||
|
@ -2590,8 +2590,7 @@ const wchar_t *reader_readline(int nchars) {
|
|||
complete_flags_t complete_flags = COMPLETION_REQUEST_DEFAULT |
|
||||
COMPLETION_REQUEST_DESCRIPTIONS |
|
||||
COMPLETION_REQUEST_FUZZY_MATCH;
|
||||
data->complete_func(buffcpy, &comp, complete_flags,
|
||||
env_vars_snapshot_t::current());
|
||||
data->complete_func(buffcpy, &comp, complete_flags);
|
||||
|
||||
// Munge our completions.
|
||||
completions_sort_and_prioritize(&comp);
|
||||
|
|
|
@ -158,7 +158,7 @@ void reader_pop();
|
|||
/// - The command to be completed as a null terminated array of wchar_t
|
||||
/// - An array_list_t in which completions will be inserted.
|
||||
typedef void (*complete_function_t)(const wcstring &, std::vector<completion_t> *,
|
||||
completion_request_flags_t, const env_vars_snapshot_t &);
|
||||
completion_request_flags_t);
|
||||
void reader_set_complete_function(complete_function_t);
|
||||
|
||||
/// The type of a highlight function.
|
||||
|
|
Loading…
Reference in a new issue