diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-08-14 13:12:44 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-08-14 13:12:44 +0100 |
| commit | 92d3178305f178e6ccc605482bb57d3e9169e7c5 (patch) | |
| tree | d540ff35ef2a4927d2f48190cd2a2df251e93e36 /src/input_handler.cc | |
| parent | 5f115c90fff3b2fc0ee4490904201b34aecfd327 (diff) | |
Clamp m_anchor in mouse handler, nothing garantees that it is still valid
Fixes #350
Diffstat (limited to 'src/input_handler.cc')
| -rw-r--r-- | src/input_handler.cc | 9 |
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) |
