summaryrefslogtreecommitdiff
path: root/src/buffer.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-08-04 11:39:28 +0700
committerMaxime Coste <mawww@kakoune.org>2017-08-04 11:39:28 +0700
commitfc64369f9d8d3279f73b89fdd76df2fa1468ff72 (patch)
tree1efec616364f72c6ca00cc7ec754cb8f6aa49efb /src/buffer.cc
parent45a7496f545bf7b10940bc55c27ddf018a1ffd17 (diff)
Purge history on buffer reload when NoUndo flag is on
We were preserving the history in that case, so on fifo buffers (that set the NoUndo flag until the fifo is closed), we still had the history from the "previous life" of the buffer, leading crashes when trying to apply it. Fixes #1518
Diffstat (limited to 'src/buffer.cc')
-rw-r--r--src/buffer.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/buffer.cc b/src/buffer.cc
index b85d01ee..147e1bbf 100644
--- a/src/buffer.cc
+++ b/src/buffer.cc
@@ -242,10 +242,13 @@ void Buffer::reload(StringView data, timespec fs_timestamp)
if (not record_undo)
{
- m_changes.push_back({ Change::Erase, {0,0}, line_count() });
+ // Erase history about to be invalidated history
+ m_history_cursor = &m_history;
+ m_last_save_history_cursor = &m_history;
+ m_history = HistoryNode{m_next_history_id++, nullptr};
+ m_changes.push_back({ Change::Erase, {0,0}, line_count() });
static_cast<BufferLines&>(m_lines) = std::move(parsed_lines.lines);
-
m_changes.push_back({ Change::Insert, {0,0}, line_count() });
}
else
@@ -340,7 +343,7 @@ bool Buffer::redo(size_t count) noexcept
while (count-- != 0 and m_history_cursor->redo_child)
{
- m_history_cursor = m_history_cursor->redo_child.get();
+ m_history_cursor = m_history_cursor->redo_child;
for (const Modification& modification : m_history_cursor->undo_group)
apply_modification(modification);