diff --git a/Userland/DevTools/HackStudio/AutoCompleteResponse.h b/Userland/DevTools/HackStudio/AutoCompleteResponse.h index 17e805b722..cc4a97a48e 100644 --- a/Userland/DevTools/HackStudio/AutoCompleteResponse.h +++ b/Userland/DevTools/HackStudio/AutoCompleteResponse.h @@ -22,6 +22,7 @@ inline bool encode(IPC::Encoder& encoder, const GUI::AutocompleteProvider::Entry encoder << (u64)response.partial_input_length; encoder << (u32)response.kind; encoder << (u32)response.language; + encoder << response.display_text; return true; } @@ -34,7 +35,8 @@ inline bool decode(IPC::Decoder& decoder, GUI::AutocompleteProvider::Entry& resp bool ok = decoder.decode(response.completion) && decoder.decode(partial_input_length) && decoder.decode(kind) - && decoder.decode(language); + && decoder.decode(language) + && decoder.decode(response.display_text); if (ok) { response.kind = static_cast(kind); diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp index 6e06061cc6..136108f3c6 100644 --- a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp +++ b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp @@ -33,6 +33,7 @@ public: __ModelRoleCustom = (int)GUI::ModelRole::Custom, PartialInputLength, Kind, + Completion, }; virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_suggestions.size(); } @@ -42,7 +43,10 @@ public: auto& suggestion = m_suggestions.at(index.row()); if (role == GUI::ModelRole::Display) { if (index.column() == Column::Name) { - return suggestion.completion; + if (!suggestion.display_text.is_empty()) + return suggestion.display_text; + else + return suggestion.completion; } if (index.column() == Column::Icon) { if (suggestion.language == GUI::AutocompleteProvider::Language::Cpp) { @@ -67,6 +71,9 @@ public: if ((int)role == InternalRole::PartialInputLength) return (i64)suggestion.partial_input_length; + if ((int)role == InternalRole::Completion) + return suggestion.completion; + return {}; } @@ -173,8 +180,8 @@ void AutocompleteBox::apply_suggestion() if (!selected_index.is_valid() || !m_suggestion_view->model()->is_within_range(selected_index)) return; - auto suggestion_index = m_suggestion_view->model()->index(selected_index.row(), AutocompleteSuggestionModel::Column::Name); - auto suggestion = suggestion_index.data().to_string(); + auto suggestion_index = m_suggestion_view->model()->index(selected_index.row()); + auto suggestion = suggestion_index.data((GUI::ModelRole)AutocompleteSuggestionModel::InternalRole::Completion).to_string(); size_t partial_length = suggestion_index.data((GUI::ModelRole)AutocompleteSuggestionModel::InternalRole::PartialInputLength).to_i64(); VERIFY(suggestion.length() >= partial_length); diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.h b/Userland/Libraries/LibGUI/AutocompleteProvider.h index 4a455f89a7..109ec94060 100644 --- a/Userland/Libraries/LibGUI/AutocompleteProvider.h +++ b/Userland/Libraries/LibGUI/AutocompleteProvider.h @@ -37,6 +37,7 @@ public: size_t partial_input_length { 0 }; CompletionKind kind { CompletionKind::Identifier }; Language language { Language::Unspecified }; + String display_text {}; }; struct ProjectLocation {