diff --git a/history.c b/history.c index c34997b39..108cbeedf 100644 --- a/history.c +++ b/history.c @@ -127,8 +127,8 @@ static void history_load( wchar_t *name ) Use a hashtable to check for duplicates instead. */ - if( !hash_get( &used, - buff ) ) + if( wcslen(buff) && !hash_get( &used, + buff ) ) { history_count++; @@ -465,10 +465,7 @@ const wchar_t *history_prev_match( const wchar_t *str ) if( history_current->prev == 0 ) { - if( history_test( str, history_current->data ) ) - return (wchar_t *)history_current->data; - else - return str; + return str; } if( past_end ) past_end = 0; diff --git a/reader.c b/reader.c index 3428d2c88..c41839160 100644 --- a/reader.c +++ b/reader.c @@ -1889,6 +1889,7 @@ static void handle_token_history( int forward, int reset ) } + current_pos = data->token_history_pos; if( forward || data->search_pos < (al_get_count( &data->search_prev )-1) ) @@ -1930,6 +1931,7 @@ static void handle_token_history( int forward, int reset ) history already contains the search string itself, if so return, otherwise add it. */ + const wchar_t *last = al_get( &data->search_prev, al_get_count( &data->search_prev ) -1 ); if( wcscmp( last, data->search_buff ) ) { @@ -1942,6 +1944,9 @@ static void handle_token_history( int forward, int reset ) } else { + + debug( 3, L"new '%ls'", data->token_history_buff ); + for( tok_init( &tok, data->token_history_buff, TOK_ACCEPT_UNFINISHED ); tok_has_next( &tok); tok_next( &tok )) @@ -1952,11 +1957,12 @@ static void handle_token_history( int forward, int reset ) { if( wcsstr( tok_last( &tok ), data->search_buff ) ) { -// fwprintf( stderr, L"Found token at pos %d\n", tok_get_pos( &tok ) ); + debug( 3, L"Found token at pos %d\n", tok_get_pos( &tok ) ); if( tok_get_pos( &tok ) >= current_pos ) { break; } + debug( 3, L"ok pos" ); if( !contains( tok_last( &tok ), &data->search_prev ) ) {