aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2021-07-05 21:37:33 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2021-07-05 21:37:33 +0200
commit3c5f69bb60f858f471121adaf172edb47628188e (patch)
tree9864be261431f674f36b0615479bd410fef2652b /src
parent70cb2ffaccb91eff6f4afe2552d0784e279f1fe9 (diff)
completeInstallable: also match for already typed prefixes
Diffstat (limited to 'src')
-rw-r--r--src/libcmd/installables.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc
index 49f063334..5f263061b 100644
--- a/src/libcmd/installables.cc
+++ b/src/libcmd/installables.cc
@@ -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 {