mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 14:03:58 +00:00
Do not complete using switches after a '--' has been encountered
darcs-hash:20070110124528-ac50b-111f01af0701f2fcc2bd22a7666b74497835356a.gz
This commit is contained in:
parent
a3aba0269d
commit
e110b29c2f
1 changed files with 82 additions and 64 deletions
30
complete.c
30
complete.c
|
@ -1652,6 +1652,7 @@ void complete_load( const wchar_t *name, int reload )
|
|||
static int complete_param( wchar_t *cmd_orig,
|
||||
wchar_t *popt,
|
||||
wchar_t *str,
|
||||
int use_switches,
|
||||
array_list_t *comp_out )
|
||||
{
|
||||
complete_entry_t *i;
|
||||
|
@ -1674,9 +1675,14 @@ static int complete_param( wchar_t *cmd_orig,
|
|||
wchar_t *match = i->cmd_type?path:cmd;
|
||||
|
||||
if( ( (!wildcard_match( match, i->cmd ) ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
use_common=1;
|
||||
if( use_switches )
|
||||
{
|
||||
|
||||
if( str[0] == L'-' )
|
||||
{
|
||||
/* Check if we are entering a combined option and argument
|
||||
|
@ -1743,6 +1749,7 @@ static int complete_param( wchar_t *cmd_orig,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( use_common )
|
||||
{
|
||||
|
@ -1764,7 +1771,7 @@ static int complete_param( wchar_t *cmd_orig,
|
|||
complete_from_args( str, o->comp, C_(o->desc), comp_out );
|
||||
}
|
||||
|
||||
if( wcslen(str) > 0 )
|
||||
if( wcslen(str) > 0 && use_switches )
|
||||
{
|
||||
/*
|
||||
Check if the short style option matches
|
||||
|
@ -2062,6 +2069,7 @@ void complete( const wchar_t *cmd,
|
|||
int use_command = 1;
|
||||
int use_function = 1;
|
||||
int use_builtin = 1;
|
||||
int had_ddash = 0;
|
||||
|
||||
CHECK( cmd, );
|
||||
CHECK( comp, );
|
||||
|
@ -2124,9 +2132,11 @@ void complete( const wchar_t *cmd,
|
|||
{
|
||||
case TOK_STRING:
|
||||
{
|
||||
wchar_t *ncmd = tok_last( &tok );
|
||||
int is_ddash = wcscmp( ncmd, L"--" ) == 0;
|
||||
|
||||
if( !had_cmd )
|
||||
{
|
||||
wchar_t *ncmd = tok_last( &tok );
|
||||
if( parser_is_subcommand( ncmd ) )
|
||||
{
|
||||
if( wcscmp( ncmd, L"builtin" )==0)
|
||||
|
@ -2144,9 +2154,8 @@ void complete( const wchar_t *cmd,
|
|||
break;
|
||||
}
|
||||
|
||||
int is_ddash = wcscmp( ncmd, L"--" ) != 0;
|
||||
|
||||
if( is_ddash ||
|
||||
if( !is_ddash ||
|
||||
( (use_command && use_function && use_builtin ) ) )
|
||||
{
|
||||
|
||||
|
@ -2158,6 +2167,14 @@ void complete( const wchar_t *cmd,
|
|||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if( is_ddash )
|
||||
{
|
||||
had_ddash = 1;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2165,6 +2182,7 @@ void complete( const wchar_t *cmd,
|
|||
case TOK_PIPE:
|
||||
case TOK_BACKGROUND:
|
||||
had_cmd=0;
|
||||
had_ddash = 0;
|
||||
use_command = 1;
|
||||
use_function = 1;
|
||||
use_builtin = 1;
|
||||
|
@ -2263,9 +2281,9 @@ void complete( const wchar_t *cmd,
|
|||
expanded. This is potentially very slow.
|
||||
*/
|
||||
|
||||
int do_file;
|
||||
int do_file=0;
|
||||
|
||||
do_file = complete_param( current_command, prev_token, current_token, comp );
|
||||
do_file = complete_param( current_command, prev_token, current_token, !had_ddash, comp );
|
||||
|
||||
/*
|
||||
If we have found no command specific completions at
|
||||
|
|
Loading…
Reference in a new issue