Clamp m_anchor in mouse handler, nothing garantees that it is still valid
Fixes #350
This commit is contained in:
parent
5f115c90ff
commit
92d3178305
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user