mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
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.
This commit is contained in:
parent
f0862cf2b7
commit
2427f3b38b
2 changed files with 20 additions and 1 deletions
|
@ -37,12 +37,24 @@ namespace Line {
|
|||
// FIXME: These objects are pretty heavy since they store two copies of text
|
||||
// somehow get rid of one
|
||||
struct CompletionSuggestion {
|
||||
private:
|
||||
struct ForSearchTag {
|
||||
};
|
||||
|
||||
public:
|
||||
static constexpr ForSearchTag ForSearch {};
|
||||
|
||||
// intentionally not explicit (allows suggesting bare strings)
|
||||
CompletionSuggestion(const String& completion)
|
||||
: CompletionSuggestion(completion, "", {})
|
||||
{
|
||||
}
|
||||
|
||||
CompletionSuggestion(const String& completion, ForSearchTag)
|
||||
: text_string(completion)
|
||||
{
|
||||
}
|
||||
|
||||
CompletionSuggestion(const StringView& completion, const StringView& trailing_trivia)
|
||||
: CompletionSuggestion(completion, trailing_trivia, {})
|
||||
{
|
||||
|
@ -52,7 +64,7 @@ struct CompletionSuggestion {
|
|||
|
||||
bool operator==(const CompletionSuggestion& suggestion) const
|
||||
{
|
||||
return suggestion.text == text;
|
||||
return suggestion.text_string == text_string;
|
||||
}
|
||||
|
||||
Vector<u32> text;
|
||||
|
@ -63,6 +75,7 @@ struct CompletionSuggestion {
|
|||
Utf32View text_view;
|
||||
Utf32View trivia_view;
|
||||
String text_string;
|
||||
bool is_valid { false };
|
||||
};
|
||||
|
||||
class SuggestionManager {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue