mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Ensure we clear first_unwritten_new_item_index after history::merge
Prevents an issue where we think we've written out history items, but we haven't, and so they get lost. Fixes #3496
This commit is contained in:
parent
13a4ef80b3
commit
9b4310b10f
2 changed files with 19 additions and 0 deletions
|
@ -2820,6 +2820,24 @@ void history_tests_t::test_history_merge(void) {
|
|||
}
|
||||
}
|
||||
|
||||
// Make sure incorporate_external_changes doesn't drop items! (#3496)
|
||||
history_t * const writer = hists[0];
|
||||
history_t * const reader = hists[1];
|
||||
const wcstring more_texts[] = {
|
||||
L"Item_#3496_1", L"Item_#3496_2", L"Item_#3496_3", L"Item_#3496_4",
|
||||
L"Item_#3496_5", L"Item_#3496_6"
|
||||
};
|
||||
for (size_t i=0; i < sizeof more_texts / sizeof *more_texts; i++) {
|
||||
// time_barrier because merging will ignore items that may be newer
|
||||
if (i > 0) time_barrier();
|
||||
writer->add(more_texts[i]);
|
||||
writer->incorporate_external_changes();
|
||||
reader->incorporate_external_changes();
|
||||
for (size_t j=0; j < i; j++) {
|
||||
do_test(history_contains(reader, more_texts[j]));
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up.
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
delete hists[i];
|
||||
|
|
|
@ -1652,6 +1652,7 @@ void history_t::incorporate_external_changes() {
|
|||
// We'll pick them up from the file (#2312)
|
||||
this->save_internal(false);
|
||||
this->new_items.clear();
|
||||
this->first_unwritten_new_item_index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue