mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 13:05:25 -05:00
fix: Fixed ImHex crashing when using ctrl-backspace on empty file. (#2433)
Editor was attempting to delete non-existent chars which is UB. Fixed by checking before deleting. Also fixed was a problem created by having to press enter to change the search string which advanced the selection to the first match. In the next step one would expect that pressing enter on the replace field would replace the selected item but was replacing the item found after he first. This was fixed by always replacing the current selection first. If the replacement is the same as the searched term then replacing won't advance the cursor, but if they are different then the current match will no longer exist so it would search fora new one.
This commit is contained in:
@@ -59,6 +59,12 @@ namespace hex::ui {
|
||||
Coordinates getSelectedColumns();
|
||||
bool isSingleLine();
|
||||
bool contains(Coordinates coordinates, int8_t endsInclusive=1);
|
||||
bool operator==(const Selection &o) const {
|
||||
return m_start == o.m_start && m_end == o.m_end;
|
||||
}
|
||||
bool operator!=(const Selection &o) const {
|
||||
return m_start != o.m_start || m_end != o.m_end;
|
||||
}
|
||||
};
|
||||
|
||||
struct EditorState {
|
||||
@@ -72,7 +78,7 @@ namespace hex::ui {
|
||||
typedef std::vector<EditorState> Matches;
|
||||
Matches &getMatches() { return m_matches; }
|
||||
bool findNext(TextEditor *editor);
|
||||
u32 findMatch(TextEditor *editor, bool isNex);
|
||||
u32 findMatch(TextEditor *editor, i32 index);
|
||||
bool replace(TextEditor *editor, bool right);
|
||||
bool replaceAll(TextEditor *editor);
|
||||
std::string &getFindWord() { return m_findWord; }
|
||||
@@ -687,7 +693,6 @@ namespace hex::ui {
|
||||
bool m_raiseContextMenu = false;
|
||||
Coordinates m_focusAtCoords = {};
|
||||
bool m_updateFocus = false;
|
||||
bool m_ensureCursorVisible = false;
|
||||
|
||||
std::vector<std::string> m_clickableText;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user