From 279121fa100b1a44236308ace6358041eaead4b1 Mon Sep 17 00:00:00 2001 From: Mart G Date: Wed, 12 Oct 2022 17:17:30 +0200 Subject: [PATCH] HexEditor: Fix two off-by-one errors The 'select all' feature now also selects the last byte of the document. The find function now also selects the last byte of a match. --- Userland/Applications/HexEditor/HexEditor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Applications/HexEditor/HexEditor.cpp b/Userland/Applications/HexEditor/HexEditor.cpp index 9093aa6013f..98c6e86a1ec 100644 --- a/Userland/Applications/HexEditor/HexEditor.cpp +++ b/Userland/Applications/HexEditor/HexEditor.cpp @@ -668,7 +668,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event) void HexEditor::select_all() { - highlight(0, m_document->size() - 1); + highlight(0, m_document->size()); set_position(0); } @@ -683,7 +683,7 @@ Optional HexEditor::find_and_highlight(ByteBuffer& needle, size_t start) { auto end_of_match = find(needle, start); if (end_of_match.has_value()) { - highlight(end_of_match.value() - needle.size(), end_of_match.value() - 1); + highlight(end_of_match.value() - needle.size(), end_of_match.value()); } return end_of_match; }