diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2016-06-23 22:02:39 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2016-06-23 22:03:07 -0700 |
commit | 02cef2da23b022cf2703fdf856fdf00b452d67fb (patch) | |
tree | 57639bdb9c83210421184d082b13e29872987a88 | |
parent | 9c53019d95c7b73f14c8bb39cddadacab16d0bf9 (diff) |
history --merge to properly interleave items
Fixes #2312
-rw-r--r-- | src/fish_tests.cpp | 11 | ||||
-rw-r--r-- | src/history.cpp | 6 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index b234fa03..4c15f498 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -2721,6 +2721,17 @@ void history_tests_t::test_history_merge(void) { for (size_t i = 0; i < count; i++) { hists[i]->incorporate_external_changes(); } + + // Everyone should also have items in the same order (#2312) + wcstring string_rep; + hists[0]->get_string_representation(&string_rep, L"\n"); + for (size_t i = 0; i < count; i++) { + wcstring string_rep2; + hists[i]->get_string_representation(&string_rep2, L"\n"); + do_test(string_rep == string_rep2); + } + + // Add some more per-history items. for (size_t i = 0; i < count; i++) { hists[i]->add(alt_texts[i]); diff --git a/src/history.cpp b/src/history.cpp index 48469759..44c153a5 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -1548,6 +1548,12 @@ void history_t::incorporate_external_changes() { if (new_timestamp > this->boundary_timestamp) { this->boundary_timestamp = new_timestamp; this->clear_file_state(); + + // We also need to erase new_items, since we go through those first, and that means we + // will not properly interleave them with items from other instances. + // We'll pick them up from the file (#2312) + this->save_internal(false); + this->new_items.clear(); } } |