From 761522a5401df6fcdff9f54d70e07fe6337b33e7 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 13 Nov 2020 00:42:29 +0100 Subject: [PATCH] Fixed highlighting calculating sizes wrongly --- source/views/view_pattern.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/views/view_pattern.cpp b/source/views/view_pattern.cpp index 6a80742a8..7d3b0e762 100644 --- a/source/views/view_pattern.cpp +++ b/source/views/view_pattern.cpp @@ -139,7 +139,7 @@ namespace hex { s32 ViewPattern::highlightUsingDecls(std::vector &ast, lang::ASTNodeTypeDecl* currTypeDeclNode, lang::ASTNodeVariableDecl* currVarDecl, u64 offset) { if (currTypeDeclNode->getAssignedType() != lang::Token::TypeToken::Type::CustomType) { - size_t size = (static_cast(currTypeDeclNode->getAssignedType()) >> 4) * currVarDecl->getArraySize(); + size_t size = (static_cast(currTypeDeclNode->getAssignedType()) >> 4); this->setHighlight(offset, size, currVarDecl->getVariableName()); offset += size; @@ -191,19 +191,22 @@ namespace hex { offset += size; } - offset += size; foundType = true; break; } for (auto &typeDeclNode : findNodes(lang::ASTNode::Type::TypeDecl, ast)) if (typeDeclNode->getTypeName() == var->getCustomVariableTypeName()) { - auto size = this->highlightUsingDecls(ast, typeDeclNode, var, offset); + size_t size = 0; + for (size_t i = 0; i < var->getArraySize(); i++) { + size = this->highlightUsingDecls(ast, typeDeclNode, var, offset); - if (size == -1) - return -1; + if (size == -1) + return -1; + + offset += size; + } - offset = size; foundType = true; break; }