summaryrefslogtreecommitdiff
path: root/src/window.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-06-13 05:00:35 +1000
committerMaxime Coste <mawww@kakoune.org>2018-06-13 05:00:35 +1000
commitee19497d3787e1ec2f144dd33ea628d42af0f255 (patch)
treecea521ec21544fa3aafe12cb598d21eba65bb5fe /src/window.cc
parent0bdde991eafb22f0dc160084050141892d3a9d41 (diff)
Fix crash when adapting window position post buffer modifications
Diffstat (limited to 'src/window.cc')
-rw-r--r--src/window.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/window.cc b/src/window.cc
index fa932778..a17bc45e 100644
--- a/src/window.cc
+++ b/src/window.cc
@@ -130,9 +130,10 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context)
{
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);
+ if (change.type == Buffer::Change::Insert and change.begin.line < m_position.line)
+ m_position.line += change.end.line - change.begin.line;
+ if (change.type == Buffer::Change::Erase and change.begin.line < m_position.line)
+ m_position.line = std::max(m_position.line - (change.end.line - change.begin.line), change.begin.line);
}
}