mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-11 07:34:32 +00:00
Fixed reader.cpp to not show garbage while showing help on auto completing (on pressin tab) for executables like "ls -"
This commit is contained in:
parent
7e124cf95e
commit
c959584831
7 changed files with 22 additions and 18 deletions
|
@ -3894,9 +3894,13 @@ void builtin_get_names( array_list_t *list )
|
|||
}
|
||||
|
||||
void builtin_get_names2(std::vector<completion_t> &list) {
|
||||
for (int i=0;i<builtin.size; ++i) {
|
||||
for (int i=0;i<builtin.size ; ++i) {
|
||||
completion_t data_to_push;
|
||||
data_to_push.completion = (wchar_t*) builtin.arr[i].key;
|
||||
|
||||
if (builtin.arr[i].key == 0)
|
||||
continue;
|
||||
|
||||
data_to_push.completion = (wchar_t*)builtin.arr[i].key;
|
||||
list.push_back( data_to_push );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ wchar_t **completions_to_char_arr( std::vector<completion_t> &l )
|
|||
}
|
||||
for( i=0; i< l.size(); i++ )
|
||||
{
|
||||
res[i] = (wchar_t *)l.at(i).completion.c_str();
|
||||
res[i] = const_cast<wchar_t*>(l.at(i).completion.c_str());
|
||||
}
|
||||
res[i]='\0';
|
||||
return res;
|
||||
|
|
|
@ -1131,7 +1131,7 @@ static void complete_cmd( const wchar_t *cmd,
|
|||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
add_slash = nxt_path[path_len-1]!=L'/';
|
||||
nxt_completion = wcsdupcat( nxt_path,
|
||||
add_slash?L"/":L"",
|
||||
|
|
2
exec.cpp
2
exec.cpp
|
@ -1745,7 +1745,7 @@ int exec_subshell( const wchar_t *cmd,
|
|||
|
||||
CHECK( cmd, -1 );
|
||||
// ifs = env_get(L"IFS");
|
||||
const env_var_t ifs = env_get_string(L"IFS").empty()?NULL:env_get_string(L"IFS").c_str();
|
||||
const env_var_t ifs = env_get_string(L"IFS");
|
||||
|
||||
if( ! ifs.missing_or_empty() )
|
||||
{
|
||||
|
|
15
expand.cpp
15
expand.cpp
|
@ -691,7 +691,7 @@ static int expand_pid( wchar_t *in,
|
|||
if( wcscmp( (in+1), SELF_STR )==0 )
|
||||
{
|
||||
wchar_t *str= (wchar_t *)malloc( sizeof(wchar_t)*32);
|
||||
// free(in);
|
||||
free(in);
|
||||
swprintf( str, 32, L"%d", getpid() );
|
||||
|
||||
completion_t data_to_push;
|
||||
|
@ -1787,7 +1787,8 @@ static int expand_cmdsubst2( const wcstring &input, std::vector<completion_t> &o
|
|||
const wchar_t * const in = input.c_str();
|
||||
|
||||
completion_t data_to_push;
|
||||
switch( parse_util_locate_cmdsubst(in,
|
||||
int parse_ret;
|
||||
switch( parse_ret = parse_util_locate_cmdsubst(in,
|
||||
¶n_begin,
|
||||
¶n_end,
|
||||
0 ) )
|
||||
|
@ -2059,7 +2060,7 @@ static void remove_internal_separator2( wcstring &s, int conv )
|
|||
|
||||
int expand_string2( const wcstring &input, std::vector<completion_t> &output, int flags )
|
||||
{
|
||||
std::vector<completion_t> list1, list2;
|
||||
std::vector<completion_t> list1, list2;
|
||||
std::vector<completion_t> *in, *out;
|
||||
|
||||
size_t i;
|
||||
|
@ -2127,7 +2128,7 @@ int expand_string2( const wcstring &input, std::vector<completion_t> &output, in
|
|||
}
|
||||
else
|
||||
{
|
||||
if(!expand_variables2( next.empty()?NULL:const_cast<wchar_t*>(next.c_str()), *out, next.size() - 1 ))
|
||||
if(!expand_variables2( const_cast<wchar_t*>(next.c_str()), *out, next.size() - 1 ))
|
||||
{
|
||||
return EXPAND_ERROR;
|
||||
}
|
||||
|
@ -2143,7 +2144,7 @@ int expand_string2( const wcstring &input, std::vector<completion_t> &output, in
|
|||
{
|
||||
wcstring next = in->at(i).completion;
|
||||
|
||||
if( !expand_brackets( const_cast<wchar_t*>(next.c_str()), flags, *out ))
|
||||
if( !expand_brackets( wcsdup(next.c_str()), flags, *out ))
|
||||
{
|
||||
return EXPAND_ERROR;
|
||||
}
|
||||
|
@ -2169,7 +2170,7 @@ int expand_string2( const wcstring &input, std::vector<completion_t> &output, in
|
|||
interested in other completions, so we
|
||||
short-circut and return
|
||||
*/
|
||||
expand_pid( const_cast<wchar_t*>(next.c_str()), flags, output );
|
||||
expand_pid( wcsdup(next.c_str()), flags, output );
|
||||
return EXPAND_OK;
|
||||
}
|
||||
else
|
||||
|
@ -2181,7 +2182,7 @@ int expand_string2( const wcstring &input, std::vector<completion_t> &output, in
|
|||
}
|
||||
else
|
||||
{
|
||||
if( !expand_pid( const_cast<wchar_t*>(next.c_str()), flags, *out ) )
|
||||
if( !expand_pid( wcsdup(next.c_str()), flags, *out ) )
|
||||
{
|
||||
return EXPAND_ERROR;
|
||||
}
|
||||
|
|
|
@ -1225,14 +1225,14 @@ static void run_pager( wchar_t *prefix, int is_quoted, const std::vector<complet
|
|||
else
|
||||
{
|
||||
wcstring foo_wstr = escape_string( el.completion, ESCAPE_ALL | ESCAPE_NO_QUOTED );
|
||||
foo = foo_wstr.empty()?NULL:const_cast<wchar_t*>(foo_wstr.c_str());
|
||||
foo = wcsdup(foo_wstr.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if( !el.description.empty() )
|
||||
{
|
||||
wcstring baz_wstr = escape_string( el.description, 1 );
|
||||
baz = baz_wstr.empty()?NULL:const_cast<wchar_t*>(baz_wstr.c_str());
|
||||
baz = wcsdup(baz_wstr.c_str());
|
||||
}
|
||||
|
||||
if( !foo )
|
||||
|
@ -1254,8 +1254,8 @@ static void run_pager( wchar_t *prefix, int is_quoted, const std::vector<complet
|
|||
foo );
|
||||
}
|
||||
|
||||
// free( foo );
|
||||
// free( baz );
|
||||
free( foo );
|
||||
free( baz );
|
||||
}
|
||||
|
||||
free( escaped_separator );
|
||||
|
@ -2889,7 +2889,6 @@ wchar_t *reader_readline()
|
|||
// comp = al_halloc( 0 );
|
||||
data->complete_func( buffcpy, comp );
|
||||
|
||||
|
||||
sort_completion_list( comp );
|
||||
remove_duplicates( comp );
|
||||
|
||||
|
|
|
@ -810,7 +810,7 @@ static int wildcard_expand_internal( const wchar_t *wc,
|
|||
return -1;
|
||||
}
|
||||
|
||||
if( !wc || !base_dir || out.empty())
|
||||
if( !wc || !base_dir )
|
||||
{
|
||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue