fix: Synchronized scrolling not working correctly

This commit is contained in:
WerWolv
2023-12-24 00:06:16 +01:00
parent 020efefb25
commit 65e2f1b5af
5 changed files with 68 additions and 16 deletions

View File

@@ -74,7 +74,6 @@ namespace hex::plugin::builtin {
std::unique_ptr<Popup> m_currPopup;
PerProvider<std::optional<u64>> m_selectionStart, m_selectionEnd;
PerProvider<float> m_scrollPosition;
PerProvider<std::map<u64, color_t>> m_foregroundHighlights, m_backgroundHighlights;
};

View File

@@ -987,21 +987,15 @@ namespace hex::plugin::builtin {
if (selection != Region::Invalid()) {
m_selectionStart.get(oldProvider) = selection.getStartAddress();
m_selectionEnd.get(oldProvider) = selection.getEndAddress();
m_scrollPosition.get(oldProvider) = m_hexEditor.getScrollPosition();
}
}
m_hexEditor.setSelectionUnchecked(std::nullopt, std::nullopt);
m_hexEditor.setScrollPosition(0);
if (newProvider != nullptr) {
m_hexEditor.setSelectionUnchecked(m_selectionStart.get(newProvider), m_selectionEnd.get(newProvider));
m_hexEditor.setScrollPosition(m_scrollPosition.get(newProvider));
} else {
ImHexApi::HexEditor::clearSelection();
}
m_hexEditor.forceUpdateScrollPosition();
if (isSelectionValid()) {
EventRegionSelected::post(ImHexApi::HexEditor::ProviderRegion{ this->getSelection(), newProvider });
}