mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
Make completion system not use quoted string escapes, since it generally looks a bit confusing there
darcs-hash:20071006105131-75c98-af770878124cc19946b964c0cf772818a5bf4216.gz
This commit is contained in:
parent
3ca3b6209d
commit
fcd474afe8
9
common.c
9
common.c
|
@ -719,10 +719,13 @@ static wchar_t *escape_simple( const wchar_t *in )
|
||||||
|
|
||||||
|
|
||||||
wchar_t *escape( const wchar_t *in_orig,
|
wchar_t *escape( const wchar_t *in_orig,
|
||||||
int escape_all )
|
int flags )
|
||||||
{
|
{
|
||||||
const wchar_t *in = in_orig;
|
const wchar_t *in = in_orig;
|
||||||
|
|
||||||
|
int escape_all = flags & ESCAPE_ALL;
|
||||||
|
int no_quoted = flags & ESCAPE_NO_QUOTED;
|
||||||
|
|
||||||
wchar_t *out;
|
wchar_t *out;
|
||||||
wchar_t *pos;
|
wchar_t *pos;
|
||||||
|
|
||||||
|
@ -735,7 +738,7 @@ wchar_t *escape( const wchar_t *in_orig,
|
||||||
FATAL_EXIT();
|
FATAL_EXIT();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( wcslen( in ) == 0 )
|
if( !no_quoted && (wcslen( in ) == 0) )
|
||||||
{
|
{
|
||||||
out = wcsdup(L"''");
|
out = wcsdup(L"''");
|
||||||
if( !out )
|
if( !out )
|
||||||
|
@ -884,7 +887,7 @@ wchar_t *escape( const wchar_t *in_orig,
|
||||||
Use quoted escaping if possible, since most people find it
|
Use quoted escaping if possible, since most people find it
|
||||||
easier to read.
|
easier to read.
|
||||||
*/
|
*/
|
||||||
if( need_escape && !need_complex_escape && escape_all )
|
if( !no_quoted && need_escape && !need_complex_escape && escape_all )
|
||||||
{
|
{
|
||||||
free( out );
|
free( out );
|
||||||
out = escape_simple( in_orig );
|
out = escape_simple( in_orig );
|
||||||
|
|
15
common.h
15
common.h
|
@ -40,9 +40,24 @@
|
||||||
*/
|
*/
|
||||||
#define BYTE_MAX 0xffu
|
#define BYTE_MAX 0xffu
|
||||||
|
|
||||||
|
/*
|
||||||
|
Escape special fish syntax characters liek the semicolon
|
||||||
|
*/
|
||||||
#define UNESCAPE_SPECIAL 1
|
#define UNESCAPE_SPECIAL 1
|
||||||
|
/*
|
||||||
|
Allow incomplete escape sequences
|
||||||
|
*/
|
||||||
#define UNESCAPE_INCOMPLETE 2
|
#define UNESCAPE_INCOMPLETE 2
|
||||||
|
|
||||||
|
/**
|
||||||
|
Escape all characters, including magic characters like the semicolon
|
||||||
|
*/
|
||||||
|
#define ESCAPE_ALL 1
|
||||||
|
/**
|
||||||
|
Do not try to use 'simplified' quoted escapes, and do not use empty quotes as the empty string
|
||||||
|
*/
|
||||||
|
#define ESCAPE_NO_QUOTED 2
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Save the shell mode on startup so we can restore them on exit
|
Save the shell mode on startup so we can restore them on exit
|
||||||
|
|
|
@ -953,7 +953,7 @@ static void mangle_completions( array_list_t *l, const wchar_t *prefix )
|
||||||
if( (c == COMPLETE_ITEM_SEP) || (c==COMPLETE_SEP) || !c)
|
if( (c == COMPLETE_ITEM_SEP) || (c==COMPLETE_SEP) || !c)
|
||||||
{
|
{
|
||||||
*end = 0;
|
*end = 0;
|
||||||
wchar_t * str = escape( start, 1 );
|
wchar_t * str = escape( start, ESCAPE_ALL | ESCAPE_NO_QUOTED );
|
||||||
|
|
||||||
comp->comp_width += my_wcswidth( str );
|
comp->comp_width += my_wcswidth( str );
|
||||||
halloc_register( global_context, str );
|
halloc_register( global_context, str );
|
||||||
|
|
8
reader.c
8
reader.c
|
@ -1001,7 +1001,7 @@ static void completion_insert( const wchar_t *val, int flags )
|
||||||
|
|
||||||
if( quote == L'\0' )
|
if( quote == L'\0' )
|
||||||
{
|
{
|
||||||
replaced = escape( val, 1 );
|
replaced = escape( val, ESCAPE_ALL | ESCAPE_NO_QUOTED );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1031,7 +1031,7 @@ static void completion_insert( const wchar_t *val, int flags )
|
||||||
if( unescapable )
|
if( unescapable )
|
||||||
{
|
{
|
||||||
free( replaced );
|
free( replaced );
|
||||||
wchar_t *tmp = escape( val, 1 );
|
wchar_t *tmp = escape( val, ESCAPE_ALL | ESCAPE_NO_QUOTED );
|
||||||
replaced = wcsdupcat( L" ", tmp );
|
replaced = wcsdupcat( L" ", tmp );
|
||||||
free( tmp);
|
free( tmp);
|
||||||
replaced[0]=quote;
|
replaced[0]=quote;
|
||||||
|
@ -1134,11 +1134,11 @@ static void run_pager( wchar_t *prefix, int is_quoted, array_list_t *comp )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foo = escape( el->completion + base_len, 1 );
|
foo = escape( el->completion + base_len, ESCAPE_ALL | ESCAPE_NO_QUOTED );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foo = escape( el->completion, 1 );
|
foo = escape( el->completion, ESCAPE_ALL | ESCAPE_NO_QUOTED );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user