summaryrefslogtreecommitdiff
path: root/src/input_handler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_handler.cc')
-rw-r--r--src/input_handler.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc
index 2ab3f98c..cefe65b1 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -72,11 +72,12 @@ struct MouseHandler
if (not context.has_window())
return false;
+ Buffer& buffer = context.buffer();
if (key.modifiers == Key::Modifiers::MousePress)
{
m_dragging = true;
m_anchor = context.window().buffer_coord(key.mouse_coord());
- context.selections_write_only() = SelectionList{ context.buffer(), m_anchor };
+ context.selections_write_only() = SelectionList{ buffer, m_anchor };
return true;
}
if (key.modifiers == Key::Modifiers::MouseRelease)
@@ -85,7 +86,8 @@ struct MouseHandler
return true;
m_dragging = false;
auto cursor = context.window().buffer_coord(key.mouse_coord());
- context.selections_write_only() = SelectionList{ context.buffer(), Selection{m_anchor, cursor} };
+ context.selections_write_only() =
+ SelectionList{ buffer, Selection{buffer.clamp(m_anchor), cursor} };
return true;
}
if (key.modifiers == Key::Modifiers::MousePos)
@@ -93,7 +95,8 @@ struct MouseHandler
if (not m_dragging)
return true;
auto cursor = context.window().buffer_coord(key.mouse_coord());
- context.selections_write_only() = SelectionList{ context.buffer(), Selection{m_anchor, cursor} };
+ context.selections_write_only() =
+ SelectionList{ buffer, Selection{buffer.clamp(m_anchor), cursor} };
return true;
}
if (key.modifiers == Key::Modifiers::MouseWheelDown)