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