From 2e05845410648f72a721dc237891c625bb2812eb Mon Sep 17 00:00:00 2001
From: WerWolv <werwolv98@gmail.com>
Date: Thu, 7 Oct 2021 16:25:59 +0200
Subject: [PATCH] ui: Improved command palette

---
 plugins/builtin/source/content/command_palette_commands.cpp | 4 ++--
 source/views/view_command_palette.cpp                       | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/plugins/builtin/source/content/command_palette_commands.cpp b/plugins/builtin/source/content/command_palette_commands.cpp
index d3fed49c9..c12b8e464 100644
--- a/plugins/builtin/source/content/command_palette_commands.cpp
+++ b/plugins/builtin/source/content/command_palette_commands.cpp
@@ -28,9 +28,9 @@ namespace hex::plugin::builtin {
 
 
                     if (result.has_value())
-                        return hex::format("#{0} = %{1}", input.data(), result.value());
+                        return hex::format("#{0} = {1}", input.data(), result.value());
                     else
-                        return hex::format("#{0} = ???", input.data());
+                        return std::string("???");
                 });
 
         ContentRegistry::CommandPaletteCommands::add(
diff --git a/source/views/view_command_palette.cpp b/source/views/view_command_palette.cpp
index 380c4e785..a6173462f 100644
--- a/source/views/view_command_palette.cpp
+++ b/source/views/view_command_palette.cpp
@@ -45,6 +45,11 @@ namespace hex {
             }
 
             if (this->m_focusInputTextBox) {
+                auto textState = ImGui::GetInputTextState(ImGui::GetID("##command_input"));
+                if (textState != nullptr) {
+                    textState->Stb.cursor = strlen(this->m_commandBuffer.data());
+                }
+
                 ImGui::SetKeyboardFocusHere(0);
                 this->m_focusInputTextBox = false;
             }