diff --git a/src/display_buffer.hh b/src/display_buffer.hh index ea945da1..3955ec25 100644 --- a/src/display_buffer.hh +++ b/src/display_buffer.hh @@ -169,7 +169,7 @@ public: private: LineList m_lines; BufferRange m_range; - size_t m_timestamp; + size_t m_timestamp = -1; }; } diff --git a/src/window.cc b/src/window.cc index 19cde54e..09babb8f 100644 --- a/src/window.cc +++ b/src/window.cc @@ -126,6 +126,16 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context) auto start_time = profile ? Clock::now() : Clock::time_point{}; + if (m_display_buffer.timestamp() != -1) + { + for (auto&& change : buffer().changes_since(m_display_buffer.timestamp())) + { + if (change.begin.line < m_position.line) + m_position.line += (change.type == Buffer::Change::Insert ? 1 : -1) * + (change.end.line - change.begin.line); + } + } + DisplayBuffer::LineList& lines = m_display_buffer.lines(); m_display_buffer.set_timestamp(buffer().timestamp()); lines.clear();