mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 01:36:39 +08:00
Handle case insensitive completions of variables better
darcs-hash:20080114010032-75c98-6e570c2b095baeb2ed2ee4d09e32f4e7d6ae47de.gz
This commit is contained in:
parent
3743a5758b
commit
a2660cfb76
|
@ -1662,7 +1662,7 @@ static int complete_variable( const wchar_t *whole_var,
|
|||
{
|
||||
sb_append_substring( &comp, whole_var, start_offset );
|
||||
sb_append( &comp, name );
|
||||
flags = COMPLETE_NO_CASE;
|
||||
flags = COMPLETE_NO_CASE | COMPLETE_DONT_ESCAPE;
|
||||
}
|
||||
|
||||
value = expand_escape_variable( value_unescaped );
|
||||
|
|
40
reader.c
40
reader.c
|
@ -1111,7 +1111,7 @@ static void completion_insert( const wchar_t *val, int flags )
|
|||
if( add_space )
|
||||
{
|
||||
|
||||
if( (quote) &&
|
||||
if( quote &&
|
||||
(data->buff[data->buff_pos] != quote ) )
|
||||
{
|
||||
/*
|
||||
|
@ -1310,13 +1310,32 @@ static void reader_flash()
|
|||
|
||||
}
|
||||
|
||||
#define UNCLEAN L"$*?({})"
|
||||
/**
|
||||
Characters that may not be part of a token that is to be replaced
|
||||
by a case insensitive completion.
|
||||
*/
|
||||
#define REPLACE_UNCLEAN L"$*?({})"
|
||||
|
||||
int reader_can_replace( const wchar_t *in )
|
||||
/**
|
||||
Check if the specified string can be replaced by a case insensitive
|
||||
complition with the specified flags.
|
||||
|
||||
Advanced tokens like those containing {}-style expansion can not at
|
||||
the moment be replaced, other than if the new token is already an
|
||||
exact replacement, e.g. if the COMPLETE_DONT_ESCAPE flag is set.
|
||||
*/
|
||||
|
||||
int reader_can_replace( const wchar_t *in, int flags )
|
||||
{
|
||||
|
||||
const wchar_t * str = in;
|
||||
|
||||
if( flags & COMPLETE_DONT_ESCAPE )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
CHECK( in, 1 );
|
||||
|
||||
/*
|
||||
|
@ -1324,7 +1343,7 @@ int reader_can_replace( const wchar_t *in )
|
|||
*/
|
||||
while( *str )
|
||||
{
|
||||
if( wcschr( UNCLEAN, *str ) )
|
||||
if( wcschr( REPLACE_UNCLEAN, *str ) )
|
||||
return 0;
|
||||
str++;
|
||||
}
|
||||
|
@ -1395,7 +1414,7 @@ static int handle_completions( array_list_t *comp )
|
|||
the token doesn't contain evil operators
|
||||
like {}
|
||||
*/
|
||||
if( !(c->flags & COMPLETE_NO_CASE) || reader_can_replace( tok ) )
|
||||
if( !(c->flags & COMPLETE_NO_CASE) || reader_can_replace( tok, c->flags ) )
|
||||
{
|
||||
completion_insert( c->completion,
|
||||
c->flags );
|
||||
|
@ -1463,8 +1482,6 @@ static int handle_completions( array_list_t *comp )
|
|||
if( begin )
|
||||
{
|
||||
|
||||
if( reader_can_replace( tok ) )
|
||||
{
|
||||
int offset = wcslen( tok );
|
||||
|
||||
count = 0;
|
||||
|
@ -1474,9 +1491,16 @@ static int handle_completions( array_list_t *comp )
|
|||
completion_t *c = (completion_t *)al_get( comp, i );
|
||||
int new_len;
|
||||
|
||||
|
||||
if( !(c->flags & COMPLETE_NO_CASE) )
|
||||
continue;
|
||||
|
||||
if( !reader_can_replace( tok, c->flags ) )
|
||||
{
|
||||
len=0;
|
||||
break;
|
||||
}
|
||||
|
||||
count++;
|
||||
|
||||
if( base )
|
||||
|
@ -1502,7 +1526,7 @@ static int handle_completions( array_list_t *comp )
|
|||
completion_insert( base, flags );
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user