Skip to content

Commit 6e3a549

Browse files
committed
Fix attrset completions
Display all available completion options within the current attrset even if it's empty or there is no text under the cursor.
1 parent 474df09 commit 6e3a549

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

nixd/lib/Controller/AST.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,16 @@ nixd::FindAttrPathResult nixd::findAttrPath(const nixf::Node &N,
313313
}
314314
}
315315

316+
if (const Node *ExprAttrs = PM.upTo(N, Node::NK_ExprAttrs)) {
317+
try {
318+
getValueAttrPath(*ExprAttrs, PM, Path);
319+
Path.emplace_back("");
320+
return R::OK;
321+
} catch (AttrPathHasDynamicError &E) {
322+
return R::WithDynamic;
323+
}
324+
}
325+
316326
return R::NotAttrPath;
317327
}
318328

nixd/lib/Controller/Completion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,13 @@ void Controller::onCompletion(const CompletionParams &Params,
384384
return Reply([&]() -> llvm::Expected<CompletionList> {
385385
const auto TU = CheckDefault(getTU(File));
386386
const auto AST = CheckDefault(getAST(*TU));
387-
388387
const auto *Desc = AST->descend({Pos, Pos});
389-
CheckDefault(Desc && Desc->children().empty());
388+
CheckDefault(Desc);
390389

391390
const auto &N = *Desc;
392391
const auto &PM = *TU->parentMap();
393392
const auto &UpExpr = *CheckDefault(PM.upExpr(N));
393+
CheckDefault(Desc->children().empty() || UpExpr.kind() == Node::NK_ExprAttrs);
394394

395395
return [&]() {
396396
CompletionList List;

0 commit comments

Comments
 (0)