HexEditor: Remove moving cursor outside bounds if selecting with mouse

Currently if users select last bytes in HexEditor with mouse in either
Hex or Text mode, they will be able to move cursor on the byte outside
bounds. If then they try to write something in either of those modes,
app will crash.

This patch moves the recently added "replace" cursor to always be on the
last byte of the selection instead of being on the byte after the last
selected byte.
This commit is contained in:
tetektoza 2023-12-15 23:08:10 +01:00 committed by Andreas Kling
parent c4c9971ed0
commit bd1d384cf6
Notes: sideshowbarker 2024-07-17 20:19:08 +09:00

View File

@ -354,7 +354,7 @@ void HexEditor::mousemove_event(GUI::MouseEvent& event)
return;
m_selection_end = offset;
m_position = offset;
m_position = (m_selection_end <= m_selection_start) ? offset : offset - 1;
scroll_position_into_view(offset);
}
@ -369,7 +369,7 @@ void HexEditor::mousemove_event(GUI::MouseEvent& event)
return;
m_selection_end = offset;
m_position = offset;
m_position = (m_selection_end <= m_selection_start) ? offset : offset - 1;
scroll_position_into_view(offset);
}
update_status();