diff options
-rw-r--r-- | Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/AutocompleteProvider.cpp | 14 |
2 files changed, 4 insertions, 13 deletions
diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp index 90cebf4719..0571ce9064 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp @@ -670,7 +670,8 @@ Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_a if (!(path.ends_with(".h") || Core::File::is_directory(LexicalPath::join(full_dir, path).string()))) continue; if (path.starts_with(partial_basename)) { - options.append({ path, partial_basename.length(), include_type, GUI::AutocompleteProvider::Language::Cpp }); + auto completion = include_type == GUI::AutocompleteProvider::CompletionKind::ProjectInclude ? String::formatted("<{}>", path) : String::formatted("\"{}\"", path); + options.append({ completion, partial_basename.length() + 1, include_type, GUI::AutocompleteProvider::Language::Cpp, path }); } } diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp index 136108f3c6..08b7538716 100644 --- a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp +++ b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp @@ -181,10 +181,10 @@ void AutocompleteBox::apply_suggestion() return; auto suggestion_index = m_suggestion_view->model()->index(selected_index.row()); - auto suggestion = suggestion_index.data((GUI::ModelRole)AutocompleteSuggestionModel::InternalRole::Completion).to_string(); + auto completion = 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); + VERIFY(completion.length() >= partial_length); if (!m_editor->has_selection()) { auto cursor = m_editor->cursor(); VERIFY(m_editor->cursor().column() >= partial_length); @@ -194,16 +194,6 @@ void AutocompleteBox::apply_suggestion() m_editor->delete_text_range(TextRange(start, end)); } - auto completion_kind = (GUI::AutocompleteProvider::CompletionKind)suggestion_index.data((GUI::ModelRole)AutocompleteSuggestionModel::InternalRole::Kind).as_u32(); - - String completion; - if (suggestion.ends_with(".h") && completion_kind == GUI::AutocompleteProvider::CompletionKind::SystemInclude) - completion = String::formatted("{}{}", suggestion, ">"); - else if (suggestion.ends_with(".h") && completion_kind == GUI::AutocompleteProvider::CompletionKind::ProjectInclude) - completion = String::formatted("{}{}", suggestion, "\""); - else - completion = suggestion; - m_editor->insert_at_cursor_or_replace_selection(completion); } |