diff --git a/plugins/builtin/source/content/views/view_command_palette.cpp b/plugins/builtin/source/content/views/view_command_palette.cpp index 4c2953df9..343972d02 100644 --- a/plugins/builtin/source/content/views/view_command_palette.cpp +++ b/plugins/builtin/source/content/views/view_command_palette.cpp @@ -28,15 +28,24 @@ namespace hex::plugin::builtin { if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape))) ImGui::CloseCurrentPopup(); - ImGui::PushItemWidth(-1); - if (ImGui::InputText( - "##command_input", this->m_commandBuffer.data(), this->m_commandBuffer.size(), ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_EnterReturnsTrue, [](ImGuiInputTextCallbackData *callbackData) -> int { - auto _this = static_cast(callbackData->UserData); - _this->m_lastResults = _this->getCommandResults(callbackData->Buf); + if (this->m_focusInputTextBox) { + auto textState = ImGui::GetInputTextState(ImGui::GetID("##command_input")); + if (textState != nullptr) { + textState->Stb.cursor = strlen(this->m_commandBuffer.data()); + } - return 0; - }, - this)) { + ImGui::SetKeyboardFocusHere(0); + this->m_focusInputTextBox = false; + } + + ImGui::PushItemWidth(-1); + if (ImGui::InputText("##command_input", this->m_commandBuffer.data(), this->m_commandBuffer.size(), ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_EnterReturnsTrue, + [](ImGuiInputTextCallbackData *callbackData) -> int { + auto _this = static_cast(callbackData->UserData); + _this->m_lastResults = _this->getCommandResults(callbackData->Buf); + + return 0; + }, this)) { if (!this->m_lastResults.empty()) { auto &[displayResult, matchedCommand, callback] = this->m_lastResults.front(); callback(matchedCommand); @@ -52,16 +61,6 @@ namespace hex::plugin::builtin { this->m_justOpened = false; } - 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; - } - ImGui::Separator(); for (const auto &[displayResult, matchedCommand, callback] : this->m_lastResults) {