diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2013-04-06 00:28:55 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2013-04-06 00:28:55 -0700 |
commit | 3a7ab3f030eda29ecbe54c0f44732e471300a3ed (patch) | |
tree | 7deb7d0f2c5c549501667f3d56fd979f8c711d5b /history.cpp | |
parent | fccf38a4d645614e31178f70f57eee2294cd4450 (diff) |
Teaching history how to exit early on thread cancellation
Diffstat (limited to 'history.cpp')
-rw-r--r-- | history.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/history.cpp b/history.cpp index 873c0f62..8d8789d6 100644 --- a/history.cpp +++ b/history.cpp @@ -21,6 +21,7 @@ #include "util.h" #include "sanity.h" #include "tokenizer.h" +#include "reader.h" #include "wutil.h" #include "history.h" @@ -1010,10 +1011,17 @@ bool history_search_t::go_backwards() if (idx == max_idx) return false; + const bool main_thread = is_main_thread(); + while (++idx < max_idx) { + if (main_thread ? reader_interrupted() : reader_thread_job_is_stale()) + { + return false; + } + const history_item_t item = history->item_at_index(idx); - /* We're done if it's empty */ + /* We're done if it's empty or we cancelled */ if (item.empty()) { return false; |