diff options
author | axel <axel@liljencrantz.se> | 2006-11-18 09:37:26 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2006-11-18 09:37:26 +1000 |
commit | b30886228c546f99f974b64101f6ca164cea25e4 (patch) | |
tree | 59d7e07df95738df11b5824fa0336931ab122645 | |
parent | f91de042695fe8b6a9f38361f835a0c86025520a (diff) |
Speed up history token search
darcs-hash:20061117233726-ac50b-eb7ef60b837a4dd5fee61c7a692d8210fdcc4719.gz
-rw-r--r-- | reader.c | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -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 ) ) |