From 3d592dbc7976fe7665e97249cc3cb092362a19f1 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 11 Mar 2024 14:00:52 +0100 Subject: [PATCH] fix: Highlighting not updating correctly when changing bookmark region Fixes #1591 --- .../source/content/views/view_bookmarks.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/plugins/builtin/source/content/views/view_bookmarks.cpp b/plugins/builtin/source/content/views/view_bookmarks.cpp index 12363bc1e..e22177552 100644 --- a/plugins/builtin/source/content/views/view_bookmarks.cpp +++ b/plugins/builtin/source/content/views/view_bookmarks.cpp @@ -313,8 +313,8 @@ namespace hex::plugin::builtin { u64 droppedBookmarkId = *static_cast(payload->Data); // Find the correct bookmark with that id - auto droppedIter = std::ranges::find_if(m_bookmarks->begin(), m_bookmarks->end(), [droppedBookmarkId](const auto &bookmark) { - return bookmark.entry.id == droppedBookmarkId; + auto droppedIter = std::ranges::find_if(m_bookmarks->begin(), m_bookmarks->end(), [droppedBookmarkId](const auto &bookmarkItem) { + return bookmarkItem.entry.id == droppedBookmarkId; }); // Swap the two bookmarks @@ -412,16 +412,25 @@ namespace hex::plugin::builtin { u64 end = region.getEndAddress(); if (!locked) { + bool updated = false; + ImGui::PushItemWidth(100_scaled); - ImGuiExt::InputHexadecimal("##begin", &begin); + if (ImGuiExt::InputHexadecimal("##begin", &begin)) + updated = true; + ImGui::SameLine(0, 0); ImGui::TextUnformatted(" - "); ImGui::SameLine(0, 0); - ImGuiExt::InputHexadecimal("##end", &end); + + if (ImGuiExt::InputHexadecimal("##end", &end)) + updated = true; + ImGui::PopItemWidth(); - if (end > begin) + if (updated && end > begin) { region = Region(begin, end - begin + 1); + EventHighlightingChanged::post(); + } } else { ImGuiExt::TextFormatted("0x{:02X} - 0x{:02X}", begin, end); }