fix: Crash when using @ command palette command

Fixes #2563
This commit is contained in:
WerWolv 2025-12-15 09:52:44 +01:00
parent cfac7ff0ba
commit cb6247b16e
1 changed files with 5 additions and 5 deletions

View File

@ -287,23 +287,23 @@ namespace hex::plugin::builtin {
"@", "@",
"hex.builtin.command.goto.desc", "hex.builtin.command.goto.desc",
[](auto input) { [](auto input) {
wolv::math_eval::MathEvaluator<long double> evaluator; wolv::math_eval::MathEvaluator<i64> evaluator;
evaluator.registerStandardVariables(); evaluator.registerStandardVariables();
evaluator.registerStandardFunctions(); evaluator.registerStandardFunctions();
std::optional<long double> result = evaluator.evaluate(input); const auto result = evaluator.evaluate(input);
if (result.has_value()) if (result.has_value())
return fmt::format("hex.builtin.command.goto.result"_lang, result.value()); return fmt::format("hex.builtin.command.goto.result"_lang, static_cast<u64>(result.value()));
else if (evaluator.hasError()) else if (evaluator.hasError())
return fmt::format("Error: {}", *evaluator.getLastError()); return fmt::format("Error: {}", *evaluator.getLastError());
else else
return std::string("???"); return std::string("???");
}, [](auto input) -> std::optional<std::string> { }, [](auto input) -> std::optional<std::string> {
wolv::math_eval::MathEvaluator<long double> evaluator; wolv::math_eval::MathEvaluator<i64> evaluator;
evaluator.registerStandardVariables(); evaluator.registerStandardVariables();
evaluator.registerStandardFunctions(); evaluator.registerStandardFunctions();
std::optional<long double> result = evaluator.evaluate(input); const auto result = evaluator.evaluate(input);
if (result.has_value()) { if (result.has_value()) {
ImHexApi::HexEditor::setSelection(result.value(), 1); ImHexApi::HexEditor::setSelection(result.value(), 1);
} }