From e720b61df6dcce3b2634d5c0e475e26812b119a6 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 3 Dec 2021 16:06:40 +0100 Subject: [PATCH] patterns: Fix casts unexpectedly increasing cursor position --- plugins/libimhex/include/hex/pattern_language/ast_node.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/libimhex/include/hex/pattern_language/ast_node.hpp b/plugins/libimhex/include/hex/pattern_language/ast_node.hpp index 29f7ed65a..86f7b9381 100644 --- a/plugins/libimhex/include/hex/pattern_language/ast_node.hpp +++ b/plugins/libimhex/include/hex/pattern_language/ast_node.hpp @@ -472,8 +472,13 @@ namespace hex::pl { auto literal = dynamic_cast(this->m_value->evaluate(evaluator)); auto type = dynamic_cast(this->m_type->evaluate(evaluator))->getType(); + auto startOffset= evaluator->dataOffset(); + auto typePattern = this->m_type->createPatterns(evaluator).front(); - ON_SCOPE_EXIT { delete typePattern; }; + ON_SCOPE_EXIT { + evaluator->dataOffset() = startOffset; + delete typePattern; + }; return std::visit(overloaded { [&, this](PatternData * value) -> ASTNode* { LogConsole::abortEvaluation(hex::format("cannot cast custom type '{}' to '{}'", value->getTypeName(), Token::getTypeName(type)), this); },