mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-20 15:25:31 +08:00
reader: Remove assert in history search
This isn't a great use of `assert` because it turns a benign "oh I need to search again" bug into a crash. Fixes #9628
This commit is contained in:
parent
14f3a5f79a
commit
7c91d009c1
|
@ -429,8 +429,15 @@ class reader_history_search_t {
|
|||
const wcstring &needle = search_string();
|
||||
if (mode_ == line || mode_ == prefix) {
|
||||
size_t offset = find(text, needle);
|
||||
assert(offset != wcstring::npos && "Should have found a match in the search result");
|
||||
add_if_new({std::move(text), offset});
|
||||
// FIXME: Previous versions asserted out if this wasn't true.
|
||||
// This could be hit with a needle of "ö" and haystack of "echo Ö"
|
||||
// I'm not sure why - this points to a bug in ifind (probably wrong locale?)
|
||||
// However, because the user experience of having it crash is horrible,
|
||||
// and the worst thing that can otherwise happen here is that a search is unsuccessful,
|
||||
// we just check it instead.
|
||||
if (offset != wcstring::npos) {
|
||||
add_if_new({std::move(text), offset});
|
||||
}
|
||||
} else if (mode_ == token) {
|
||||
auto tok = new_tokenizer(text.c_str(), TOK_ACCEPT_UNFINISHED);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user