diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-05-22 22:40:42 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-23 01:31:41 +0200 |
commit | 2427f3b38ba65948a63c61e121733bdf060851ea (patch) | |
tree | 2f97e9ae7165cec87c43b5333d30c39d7dc23796 /Libraries/LibLine/SuggestionManager.cpp | |
parent | f0862cf2b702e0298c27103aec0e6a3a0d06990d (diff) | |
download | serenity-2427f3b38ba65948a63c61e121733bdf060851ea.zip |
LibLine: Add a constructor for CompletionSuggestions purely for comparison
`CompletionSuggestion(text, ForSearch)` creates a suggestion whose only
purpose is to be compared against.
This constructor skips initialising the views.
Diffstat (limited to 'Libraries/LibLine/SuggestionManager.cpp')
-rw-r--r-- | Libraries/LibLine/SuggestionManager.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Libraries/LibLine/SuggestionManager.cpp b/Libraries/LibLine/SuggestionManager.cpp index 8284b38a20..88a8cdcde4 100644 --- a/Libraries/LibLine/SuggestionManager.cpp +++ b/Libraries/LibLine/SuggestionManager.cpp @@ -32,6 +32,7 @@ namespace Line { CompletionSuggestion::CompletionSuggestion(const StringView& completion, const StringView& trailing_trivia, Style style) : style(style) , text_string(completion) + , is_valid(true) { Utf8View text_u8 { completion }; Utf8View trivia_u8 { trailing_trivia }; @@ -49,6 +50,11 @@ CompletionSuggestion::CompletionSuggestion(const StringView& completion, const S void SuggestionManager::set_suggestions(Vector<CompletionSuggestion>&& suggestions) { m_suggestions = move(suggestions); + + // make sure we were not given invalid suggestions + for (auto& suggestion : m_suggestions) + ASSERT(suggestion.is_valid); + size_t common_suggestion_prefix { 0 }; if (m_suggestions.size() == 1) { m_largest_common_suggestion_prefix_length = m_suggestions[0].text_view.length(); |