Skip to content

Commit

Permalink
Speed up history token search
Browse files Browse the repository at this point in the history
darcs-hash:20061117233726-ac50b-eb7ef60b837a4dd5fee61c7a692d8210fdcc4719.gz
  • Loading branch information
liljencrantz committed Nov 17, 2006
1 parent f91de04 commit b308862
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1368,12 +1368,31 @@ static void handle_token_history( int forward, int reset )
{
if( current_pos == -1 )
{
wchar_t *item;

/*
Move to previous line
*/
free( (void *)data->token_history_buff );
data->token_history_buff = wcsdup( history_prev_match(L"") );
free( (void *)data->token_history_buff );

/*
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);

}

if( ! wcslen( data->token_history_buff ) )
Expand Down

0 comments on commit b308862

Please sign in to comment.