Skip to content

Commit 62732de

Browse files
committed
fix: Gaps in-between hex editor highlighting on specific scalings
1 parent 63e777c commit 62732de

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

plugins/ui/source/ui/hex_editor.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,7 @@ namespace hex::ui {
782782
auto byteCellSize = (CharacterSize * ImVec2(maxCharsPerCell, 1)) + (ImVec2(2, 2) * ImGui::GetStyle().CellPadding) + scaled(ImVec2(1 + m_byteCellPadding, 0));
783783
byteCellSize = ImVec2(std::ceil(byteCellSize.x), std::ceil(byteCellSize.y));
784784

785+
std::optional<float> prevEndPosX;
785786
for (u64 x = 0; x < columnCount; x++) {
786787
const u64 byteAddress = y * bytesPerRow + x * bytesPerCell + m_provider->getBaseAddress() + m_provider->getCurrentPageAddress();
787788

@@ -794,6 +795,7 @@ namespace hex::ui {
794795

795796
if (x < std::ceil(float(validBytes) / bytesPerCell)) {
796797
auto cellStartPos = getCellPosition();
798+
797799
auto [foregroundColor, backgroundColor] = cellColors[x];
798800

799801
auto adjustedCellSize = byteCellSize;
@@ -809,6 +811,13 @@ namespace hex::ui {
809811

810812
backgroundColor = applySelectionColor(byteAddress, backgroundColor);
811813

814+
if (prevEndPosX.has_value()) {
815+
adjustedCellSize.x += cellStartPos.x - prevEndPosX.value();
816+
cellStartPos.x = prevEndPosX.value();
817+
}
818+
819+
prevEndPosX = cellStartPos.x + adjustedCellSize.x;
820+
812821
// Draw highlights and selection
813822
if (backgroundColor.has_value()) {
814823
this->drawBackgroundHighlight(cellStartPos, adjustedCellSize, backgroundColor.value());

0 commit comments

Comments
 (0)