mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Simple prefix match for completions
This commit is contained in:
parent
ecc7759973
commit
67dcc74c79
2 changed files with 5 additions and 5 deletions
|
@ -129,7 +129,7 @@ Rectangle {
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
if (popup.opened)
|
if (popup.opened)
|
||||||
popup.completer.setSearchString(textArea.getText(completerTriggeredAt, cursorPosition));
|
popup.completer.setSearchString(textArea.getText(completerTriggeredAt, cursorPosition) + event.text);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,27 +90,27 @@ public:
|
||||||
sourceModel()->data(source_left, CompletionModel::SearchRole).toString();
|
sourceModel()->data(source_left, CompletionModel::SearchRole).toString();
|
||||||
auto left2 =
|
auto left2 =
|
||||||
sourceModel()->data(source_left, CompletionModel::SearchRole2).toString();
|
sourceModel()->data(source_left, CompletionModel::SearchRole2).toString();
|
||||||
auto left = left1.toLower().indexOf(searchString);
|
auto left = (size_t)left1.toLower().indexOf(searchString);
|
||||||
// utils::levenshtein_distance(searchString, left1.toLower().toStdString());
|
// utils::levenshtein_distance(searchString, left1.toLower().toStdString());
|
||||||
if (!left2.isEmpty()) {
|
if (!left2.isEmpty()) {
|
||||||
// left = std::min(
|
// left = std::min(
|
||||||
// utils::levenshtein_distance(searchString,
|
// utils::levenshtein_distance(searchString,
|
||||||
// left2.toLower().toStdString()), left);
|
// left2.toLower().toStdString()), left);
|
||||||
left = std::min(left2.toLower().indexOf(searchString), left);
|
left = std::min((size_t)left2.toLower().indexOf(searchString), left);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto right1 =
|
auto right1 =
|
||||||
sourceModel()->data(source_right, CompletionModel::SearchRole).toString();
|
sourceModel()->data(source_right, CompletionModel::SearchRole).toString();
|
||||||
auto right2 =
|
auto right2 =
|
||||||
sourceModel()->data(source_right, CompletionModel::SearchRole2).toString();
|
sourceModel()->data(source_right, CompletionModel::SearchRole2).toString();
|
||||||
auto right = right1.toLower().indexOf(searchString);
|
auto right = (size_t)right1.toLower().indexOf(searchString);
|
||||||
// auto right =
|
// auto right =
|
||||||
// utils::levenshtein_distance(searchString, right1.toLower().toStdString());
|
// utils::levenshtein_distance(searchString, right1.toLower().toStdString());
|
||||||
if (!right2.isEmpty()) {
|
if (!right2.isEmpty()) {
|
||||||
// right = std::min(
|
// right = std::min(
|
||||||
// utils::levenshtein_distance(searchString,
|
// utils::levenshtein_distance(searchString,
|
||||||
// right2.toLower().toStdString()), right);
|
// right2.toLower().toStdString()), right);
|
||||||
right = std::min(right2.toLower().indexOf(searchString), right);
|
right = std::min((size_t)right2.toLower().indexOf(searchString), right);
|
||||||
}
|
}
|
||||||
|
|
||||||
return left < right;
|
return left < right;
|
||||||
|
|
Loading…
Reference in a new issue