nix-community/rnix-lsp

No autocompletion with nested attribute declaration

jiegec opened this issue · 0 comments

Describe the bug

Example code:

let ab = { cd.ef = 2; }; in ab.cd.

It does not autocomplete ef.

Steps to reproduce

Steps to reproduce the behavior:

Add the following test to src/lookup.rs:

    fn test_ident_traverse_multi_attr_path() {
        let root = rnix::parse("let ab = { cd.ef = 2; }; in ab.cd. ").node();
        let mut app = App {
            files: HashMap::new(),
            conn: Connection::memory().0,
        };

        let suggestions = app.scope_for_ident(
            Url::parse("file:///default.nix").unwrap(),
            &root,
            34
        );

        assert!(suggestions.is_some());
        let val = suggestions.unwrap();
        assert!(val.1.contains_key("ef"));
    }

It fails.

Expected behavior

It should handle attrs like { cd.ef = 2; }.

Screenshots

The problem was found when trying to jump to declaration of passthru.optional-dependencies.socks:

image

It fails to jump to the attribute.

Additional context

  • Version of rnix-lsp: 0.2.5
  • Name and version of the editor you've used: VSCode 1.68.1
  • Operating system: macOS
Editor configuration "nix.enableLanguageServer": true