fix: Editing value not being updated correctly when moving to next hex cell

Fixes #538
This commit is contained in:
WerWolv
2022-06-17 10:16:58 +02:00
parent 12e99a9d4c
commit 4dcd26a21f
2 changed files with 10 additions and 6 deletions

View File

@@ -127,6 +127,7 @@ namespace hex::plugin::builtin {
std::optional<u64> m_editingAddress;
bool m_shouldModifyValue = false;
bool m_enteredEditingMode = false;
bool m_shouldUpdateEditingValue = false;
std::vector<u8> m_editingBytes;
color_t m_selectionColor = 0x00;

View File

@@ -463,6 +463,13 @@ namespace hex::plugin::builtin {
void ViewHexEditor::drawCell(u64 address, u8 *data, size_t size, bool hovered) {
auto provider = ImHexApi::Provider::get();
if (this->m_shouldUpdateEditingValue) {
this->m_shouldUpdateEditingValue = false;
this->m_editingBytes.resize(size);
std::memcpy(this->m_editingBytes.data(), data, size);
}
if (this->m_editingAddress != address) {
this->m_currDataVisualizer->draw(address, data, size, this->m_upperCaseHex);
@@ -472,9 +479,7 @@ namespace hex::plugin::builtin {
this->m_editingAddress = address;
this->m_shouldModifyValue = false;
this->m_enteredEditingMode = true;
this->m_editingBytes.resize(size);
std::memcpy(this->m_editingBytes.data(), data, size);
this->m_shouldUpdateEditingValue = true;
}
}
}
@@ -498,10 +503,8 @@ namespace hex::plugin::builtin {
this->m_editingAddress = std::nullopt;
}
this->m_editingBytes.resize(size);
std::memcpy(this->m_editingBytes.data(), data, size);
this->m_shouldModifyValue = false;
this->m_shouldUpdateEditingValue = true;
}
this->m_enteredEditingMode = false;