fix regression introduced by 21521b2

The problem was overlooking a `break` statement when refactoring a
`switch` block into a simpler `if...else...` block. This fixes the
behavior of the `history-token-search-backward` function and its forward
searching analog.

Fixes #4065
This commit is contained in:
Kurtis Rader 2017-05-25 20:46:38 -07:00
parent f9e7ca869f
commit 8f78e71b6d
2 changed files with 7 additions and 16 deletions

View file

@ -560,7 +560,6 @@ static int builtin_bind(parser_t &parser, io_streams_t &streams, wchar_t **argv)
argv[0], eseq.c_str()); argv[0], eseq.c_str());
} }
} }
break;
} else { } else {
if (builtin_bind_add(argv[w.woptind], argv + (w.woptind + 1), if (builtin_bind_add(argv[w.woptind], argv + (w.woptind + 1),
argc - (w.woptind + 1), bind_mode, sets_bind_mode, argc - (w.woptind + 1), bind_mode, sets_bind_mode,

View file

@ -1781,22 +1781,14 @@ static void handle_token_history(int forward, int reset) {
tokenizer_t tok(data->token_history_buff.c_str(), TOK_ACCEPT_UNFINISHED); tokenizer_t tok(data->token_history_buff.c_str(), TOK_ACCEPT_UNFINISHED);
tok_t token; tok_t token;
while (tok.next(&token)) { while (tok.next(&token)) {
if (token.type == TOK_STRING) { if (token.type != TOK_STRING) continue;
if (token.text.find(data->search_buff) != wcstring::npos) { if (token.text.find(data->search_buff) == wcstring::npos) continue;
// debug( 3, L"Found token at pos %d\n", tok_get_pos( &tok ) ); if (token.offset >= current_pos) continue;
if (token.offset >= current_pos) {
break;
}
// debug( 3, L"ok pos" );
if (find(data->search_prev.begin(), data->search_prev.end(), token.text) == auto found = find(data->search_prev.begin(), data->search_prev.end(), token.text);
data->search_prev.end()) { if (found == data->search_prev.end()) {
data->token_history_pos = token.offset; data->token_history_pos = token.offset;
str = token.text; str = token.text;
}
}
} else {
break;
} }
} }
} }