mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
Speed up history token search
darcs-hash:20061117233726-ac50b-eb7ef60b837a4dd5fee61c7a692d8210fdcc4719.gz
This commit is contained in:
parent
f91de04269
commit
b30886228c
23
reader.c
23
reader.c
@ -1368,12 +1368,31 @@ static void handle_token_history( int forward, int reset )
|
|||||||
{
|
{
|
||||||
if( current_pos == -1 )
|
if( current_pos == -1 )
|
||||||
{
|
{
|
||||||
|
wchar_t *item;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Move to previous line
|
Move to previous line
|
||||||
*/
|
*/
|
||||||
free( (void *)data->token_history_buff );
|
free( (void *)data->token_history_buff );
|
||||||
data->token_history_buff = wcsdup( history_prev_match(L"") );
|
|
||||||
|
/*
|
||||||
|
Search for previous item that contains this substring
|
||||||
|
*/
|
||||||
|
item = history_prev_match(data->search_buff);
|
||||||
|
|
||||||
|
/*
|
||||||
|
If there is no match, the original string is returned
|
||||||
|
|
||||||
|
If so, we clear the match string to avoid infinite loop
|
||||||
|
*/
|
||||||
|
if( wcscmp( item, data->search_buff ) == 0 )
|
||||||
|
{
|
||||||
|
item=L"";
|
||||||
|
}
|
||||||
|
|
||||||
|
data->token_history_buff = wcsdup( item );
|
||||||
current_pos = wcslen(data->token_history_buff);
|
current_pos = wcslen(data->token_history_buff);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! wcslen( data->token_history_buff ) )
|
if( ! wcslen( data->token_history_buff ) )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user