1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Basic fuzzy search for autocomplete

This commit is contained in:
Simon Lübeß 2021-12-08 22:08:57 +01:00
parent 195c705a46
commit f9f53eb97b
7 changed files with 347 additions and 20 deletions

View file

@ -8007,7 +8007,9 @@ void BfCompiler::GenerateAutocompleteInfo()
}
std::sort(entries.begin(), entries.end(), [](AutoCompleteEntry* lhs, AutoCompleteEntry* rhs)
{
return stricmp(lhs->mDisplay, rhs->mDisplay) < 0;
// TODO(FUZZY): SORT BY Score
return lhs->mScore > rhs->mScore;
//return stricmp(lhs->mDisplay, rhs->mDisplay) < 0;
});
String docString;
@ -8022,6 +8024,28 @@ void BfCompiler::GenerateAutocompleteInfo()
autoCompleteResultString += '@';
autoCompleteResultString += String(entry->mDisplay);
// TODO(FUZZY): OUTPUT
// TODO(FUZZY): this is not really efficient
autoCompleteResultString += "\x02";
for (int i = 0; i < 256; i++)
{
int match = entry->mMatches[i];
// no more matches after this
if (match == 0 && i != 0)
break;
// Need max 3 chars (largest Hex (FF) + '\0')
char buffer[3];
_itoa_s(match, buffer, 16);
autoCompleteResultString += String(buffer);
autoCompleteResultString += ",";
}
autoCompleteResultString += "X";
if (entry->mDocumentation != NULL)
{
autoCompleteResultString += '\x03';