mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-18 07:02:46 +08:00
Merge branch 'master' into documentation-update
This commit is contained in:
commit
60e7726832
|
@ -173,14 +173,16 @@ static void builtin_complete_add(const wcstring_list_t &cmd,
|
|||
static void builtin_complete_remove3(const wchar_t *cmd,
|
||||
int cmd_type,
|
||||
wchar_t short_opt,
|
||||
const wcstring_list_t &long_opt)
|
||||
const wcstring_list_t &long_opt,
|
||||
int long_mode)
|
||||
{
|
||||
for (size_t i=0; i<long_opt.size(); i++)
|
||||
{
|
||||
complete_remove(cmd,
|
||||
cmd_type,
|
||||
short_opt,
|
||||
long_opt.at(i).c_str());
|
||||
long_opt.at(i).c_str(),
|
||||
long_mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,6 +205,7 @@ static void builtin_complete_remove2(const wchar_t *cmd,
|
|||
complete_remove(cmd,
|
||||
cmd_type,
|
||||
*s,
|
||||
0,
|
||||
0);
|
||||
|
||||
}
|
||||
|
@ -211,24 +214,36 @@ static void builtin_complete_remove2(const wchar_t *cmd,
|
|||
builtin_complete_remove3(cmd,
|
||||
cmd_type,
|
||||
*s,
|
||||
gnu_opt);
|
||||
gnu_opt,
|
||||
0);
|
||||
builtin_complete_remove3(cmd,
|
||||
cmd_type,
|
||||
*s,
|
||||
old_opt);
|
||||
old_opt,
|
||||
1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (gnu_opt.empty() && old_opt.empty())
|
||||
{
|
||||
complete_remove(cmd,
|
||||
cmd_type,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
else
|
||||
{
|
||||
builtin_complete_remove3(cmd,
|
||||
cmd_type,
|
||||
0,
|
||||
gnu_opt);
|
||||
gnu_opt,
|
||||
0);
|
||||
builtin_complete_remove3(cmd,
|
||||
cmd_type,
|
||||
0,
|
||||
old_opt);
|
||||
old_opt,
|
||||
1);
|
||||
|
||||
}
|
||||
|
||||
|
|
14
complete.cpp
14
complete.cpp
|
@ -200,7 +200,7 @@ public:
|
|||
|
||||
/** Adds or removes an option. */
|
||||
void add_option(const complete_entry_opt_t &opt);
|
||||
bool remove_option(wchar_t short_opt, const wchar_t *long_opt);
|
||||
bool remove_option(wchar_t short_opt, const wchar_t *long_opt, int old_mode);
|
||||
|
||||
/** Getter for short_opt_str. */
|
||||
wcstring &get_short_opt_str();
|
||||
|
@ -464,7 +464,7 @@ completion_autoload_t::completion_autoload_t() : autoload_t(L"fish_complete_path
|
|||
/** Callback when an autoloaded completion is removed */
|
||||
void completion_autoload_t::command_removed(const wcstring &cmd)
|
||||
{
|
||||
complete_remove(cmd.c_str(), COMMAND, 0, 0);
|
||||
complete_remove(cmd.c_str(), COMMAND, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -617,7 +617,7 @@ void complete_add(const wchar_t *cmd,
|
|||
specified short / long option strings. Returns true if it is now
|
||||
empty and should be deleted, false if it's not empty. Must be called while locked.
|
||||
*/
|
||||
bool completion_entry_t::remove_option(wchar_t short_opt, const wchar_t *long_opt)
|
||||
bool completion_entry_t::remove_option(wchar_t short_opt, const wchar_t *long_opt, int old_mode)
|
||||
{
|
||||
ASSERT_IS_LOCKED(completion_lock);
|
||||
ASSERT_IS_LOCKED(completion_entry_lock);
|
||||
|
@ -630,7 +630,8 @@ bool completion_entry_t::remove_option(wchar_t short_opt, const wchar_t *long_op
|
|||
for (option_list_t::iterator iter = this->options.begin(); iter != this->options.end();)
|
||||
{
|
||||
complete_entry_opt_t &o = *iter;
|
||||
if (short_opt==o.short_opt || long_opt == o.long_opt)
|
||||
if ((short_opt && short_opt == o.short_opt) ||
|
||||
(long_opt && long_opt == o.long_opt && old_mode == o.old_mode))
|
||||
{
|
||||
/* fwprintf( stderr,
|
||||
L"remove option -%lc --%ls\n",
|
||||
|
@ -668,7 +669,8 @@ bool completion_entry_t::remove_option(wchar_t short_opt, const wchar_t *long_op
|
|||
void complete_remove(const wchar_t *cmd,
|
||||
bool cmd_is_path,
|
||||
wchar_t short_opt,
|
||||
const wchar_t *long_opt)
|
||||
const wchar_t *long_opt,
|
||||
int old_mode)
|
||||
{
|
||||
CHECK(cmd,);
|
||||
scoped_lock lock(completion_lock);
|
||||
|
@ -679,7 +681,7 @@ void complete_remove(const wchar_t *cmd,
|
|||
if (iter != completion_set.end())
|
||||
{
|
||||
completion_entry_t *entry = *iter;
|
||||
bool delete_it = entry->remove_option(short_opt, long_opt);
|
||||
bool delete_it = entry->remove_option(short_opt, long_opt, old_mode);
|
||||
if (delete_it)
|
||||
{
|
||||
/* Delete this entry */
|
||||
|
|
|
@ -207,7 +207,8 @@ void complete_set_authoritative(const wchar_t *cmd, bool cmd_type, bool authorit
|
|||
void complete_remove(const wchar_t *cmd,
|
||||
bool cmd_is_path,
|
||||
wchar_t short_opt,
|
||||
const wchar_t *long_opt);
|
||||
const wchar_t *long_opt,
|
||||
int long_mode);
|
||||
|
||||
|
||||
/** Find all completions of the command cmd, insert them into out.
|
||||
|
|
|
@ -61,14 +61,14 @@ for i in *.in
|
|||
else
|
||||
set res fail
|
||||
echo Output differs for file $i. Diff follows:
|
||||
diff tmp.out $template_out
|
||||
diff -u tmp.out $template_out
|
||||
end
|
||||
|
||||
if diff tmp.err $template_err >/dev/null
|
||||
else
|
||||
set res fail
|
||||
echo Error output differs for file $i. Diff follows:
|
||||
diff tmp.err $template_err
|
||||
diff -u tmp.err $template_err
|
||||
end
|
||||
|
||||
if test (cat tmp.status) = (cat $template_status)
|
||||
|
|
|
@ -3,9 +3,43 @@
|
|||
# We actually encountered some case that was effectively like this (Issue 2 in github)
|
||||
|
||||
complete --command AAAA -l abcd --condition 'complete -c AAAA -l efgh'
|
||||
complete -C'AAAA -'
|
||||
complete -C'AAAA -'
|
||||
echo "AAAA:"
|
||||
complete -C'AAAA -' | sort
|
||||
echo "AAAA:"
|
||||
complete -C'AAAA -' | sort
|
||||
|
||||
complete --command BBBB -l abcd --condition 'complete -e --command BBBB -l abcd'
|
||||
echo "BBBB:"
|
||||
complete -C'BBBB -'
|
||||
echo "BBBB:"
|
||||
complete -C'BBBB -'
|
||||
|
||||
# Test that erasing completions works correctly
|
||||
echo
|
||||
|
||||
function sort
|
||||
# GNU sort is really stupid, a non-C locale seems to make it assume --dictionary-order
|
||||
# If I wanted --dictionary-order, I would have specified --dictionary-order!
|
||||
env LC_ALL=C sort $argv
|
||||
end
|
||||
|
||||
complete -c CCCC -l bar
|
||||
complete -c CCCC -l baz
|
||||
complete -c CCCC -o bar
|
||||
complete -c CCCC -o foo
|
||||
complete -c CCCC -s a
|
||||
complete -c CCCC -s b
|
||||
echo "CCCC:"
|
||||
complete -C'CCCC -' | sort
|
||||
complete -c CCCC -l bar -e
|
||||
echo "CCCC:"
|
||||
complete -C'CCCC -' | sort
|
||||
complete -c CCCC -o foo -e
|
||||
echo "CCCC:"
|
||||
complete -C'CCCC -' | sort
|
||||
complete -c CCCC -s a -e
|
||||
echo "CCCC:"
|
||||
complete -C'CCCC -' | sort
|
||||
complete -c CCCC -e
|
||||
echo "CCCC:"
|
||||
complete -C'CCCC -' | sort
|
||||
|
|
|
@ -1,4 +1,32 @@
|
|||
AAAA:
|
||||
--abcd
|
||||
AAAA:
|
||||
--abcd
|
||||
--efgh
|
||||
BBBB:
|
||||
--abcd
|
||||
--abcd
|
||||
BBBB:
|
||||
|
||||
CCCC:
|
||||
--bar
|
||||
--baz
|
||||
-a
|
||||
-b
|
||||
-bar
|
||||
-foo
|
||||
CCCC:
|
||||
--baz
|
||||
-a
|
||||
-b
|
||||
-bar
|
||||
-foo
|
||||
CCCC:
|
||||
--baz
|
||||
-a
|
||||
-b
|
||||
-bar
|
||||
CCCC:
|
||||
--baz
|
||||
-b
|
||||
-bar
|
||||
CCCC:
|
||||
|
|
Loading…
Reference in New Issue
Block a user