summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMart G <martg_@hotmail.com>2022-10-12 17:17:30 +0200
committerLinus Groh <mail@linusgroh.de>2022-10-12 18:15:44 +0200
commit279121fa100b1a44236308ace6358041eaead4b1 (patch)
tree080bf4b2f89619330aaccde7c3d12e2cb453e2ac
parent6926991a56d3a113bd9dd6b92222c0351d63dc6f (diff)
downloadserenity-279121fa100b1a44236308ace6358041eaead4b1.zip
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.
-rw-r--r--Userland/Applications/HexEditor/HexEditor.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Applications/HexEditor/HexEditor.cpp b/Userland/Applications/HexEditor/HexEditor.cpp
index 9093aa6013..98c6e86a1e 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<size_t> 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;
}