diff --git a/nixd/lib/Eval/AttrSetProvider.cpp b/nixd/lib/Eval/AttrSetProvider.cpp index 9ae8cd635..b626a291c 100644 --- a/nixd/lib/Eval/AttrSetProvider.cpp +++ b/nixd/lib/Eval/AttrSetProvider.cpp @@ -264,6 +264,11 @@ void AttrSetProvider::onOptionComplete( return; } + if (nixt::isOption(state(), Scope)) { + Reply(error("scope is already an option")); + return; + } + std::vector Response; // FIXME: we may want to use "Trie" to speedup the string searching. diff --git a/nixd/tools/nixd/test/completion-option-stop.md b/nixd/tools/nixd/test/completion-option-stop.md new file mode 100644 index 000000000..56a430873 --- /dev/null +++ b/nixd/tools/nixd/test/completion-option-stop.md @@ -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"} +```