Accept and discard fragments in getFlakeRefForCompletion

Otherwise trying to complete `nix build foo#bar --update-input <Tab>`
fails with "unexpected fragment"
This commit is contained in:
Naïm Favier 2022-02-18 13:19:57 +01:00
parent c28e2b1b29
commit 7f5cf87d56
No known key found for this signature in database
GPG key ID: 49B07322580B7EE2
2 changed files with 3 additions and 3 deletions

View file

@ -134,7 +134,7 @@ struct InstallableCommand : virtual Args, SourceExprCommand
std::optional<FlakeRef> getFlakeRefForCompletion() override
{
return parseFlakeRef(_installable, absPath("."));
return parseFlakeRefWithFragment(_installable, absPath(".")).first;
}
private:

View file

@ -905,10 +905,10 @@ std::optional<FlakeRef> InstallablesCommand::getFlakeRefForCompletion()
{
if (_installables.empty()) {
if (useDefaultInstallables())
return parseFlakeRef(".", absPath("."));
return parseFlakeRefWithFragment(".", absPath(".")).first;
return {};
}
return parseFlakeRef(_installables.front(), absPath("."));
return parseFlakeRefWithFragment(_installables.front(), absPath(".")).first;
}
InstallableCommand::InstallableCommand()