Skip to content

Commit

Permalink
libnixt: stop at concrete options, rather than select into it. (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc authored Apr 29, 2024
1 parent 92cead3 commit dad49ea
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nixd/lib/Eval/AttrSetProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ void AttrSetProvider::onOptionComplete(
return;
}

if (nixt::isOption(state(), Scope)) {
Reply(error("scope is already an option"));
return;
}

std::vector<OptionField> Response;

// FIXME: we may want to use "Trie" to speedup the string searching.
Expand Down
72 changes: 72 additions & 0 deletions nixd/tools/nixd/test/completion-option-stop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# RUN: nixd --lit-test \
# RUN: --nixos-options-expr="{ foo.bar = { _type = \"option\"; }; }" \
# RUN: < %s | FileCheck %s

<-- initialize(0)

```json
{
"jsonrpc":"2.0",
"id":0,
"method":"initialize",
"params":{
"processId":123,
"rootPath":"",
"capabilities":{
},
"trace":"off"
}
}
```


<-- textDocument/didOpen


```json
{
"jsonrpc":"2.0",
"method":"textDocument/didOpen",
"params":{
"textDocument":{
"uri":"file:///completion.nix",
"languageId":"nix",
"version":1,
"text":"{ bar = 1; foo.bar. }"
}
}
}
```

```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "textDocument/completion",
"params": {
"textDocument": {
"uri": "file:///completion.nix"
},
"position": {
"line": 0,
"character": 19
},
"context": {
"triggerKind": 1
}
}
}
```

```
CHECK: "id": 1,
CHECK-NEXT: "jsonrpc": "2.0",
CHECK-NEXT: "result": {
CHECK-NEXT: "isIncomplete": false,
CHECK-NEXT: "items": []
```


```json
{"jsonrpc":"2.0","method":"exit"}
```

0 comments on commit dad49ea

Please sign in to comment.