mirror of https://github.com/WerWolv/ImHex
fix: Crash when using @ command palette command
Fixes #2563
(cherry picked from commit cb6247b16e)
This commit is contained in:
parent
81826df897
commit
b8bcb815c8
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue