completeInstallable: also match for already typed prefixes

This commit is contained in:
Maximilian Bosch 2021-07-05 21:37:33 +02:00
parent 70cb2ffacc
commit 3c5f69bb60
No known key found for this signature in database
GPG key ID: 091DBF4D1FC46B8E

View file

@ -185,9 +185,12 @@ void SourceExprCommand::completeInstallable(std::string_view prefix)
std::string prefix_ = std::string(prefix);
auto sep = prefix_.rfind('.');
std::string searchWord;
if (sep != std::string::npos) {
prefix_.erase(sep);
searchWord = prefix_.substr(sep, std::string::npos);
prefix_ = prefix_.substr(0, sep);
} else {
searchWord = prefix_;
prefix_ = "";
}
@ -198,7 +201,10 @@ void SourceExprCommand::completeInstallable(std::string_view prefix)
if (v2.type() == nAttrs) {
for (auto & i : *v2.attrs) {
completions->add(i.name);
std::string name = i.name;
if (name.find(searchWord) == 0) {
completions->add(i.name);
}
}
}
} else {