repl: tab completion doesn't work for quoted attrs #1193

Open
opened 2026-04-24 08:15:14 +00:00 by blokyk · 2 comments
Member

Describe the bug

trying to tab-complete an attribute name that needs to be quoted doesn't work if the user doesn't already know it needs to be quoted. tt also isn't considered for completion if there is another attribute with an identical prefix that doesn't need to be quoted.

Steps To Reproduce

nix-repl> a = { "tiler@crazy" = 5; tilix = 4; }

nix-repl> a.til<TAB>
nix-repl> a.tilix

nix-repl> a.tiler<TAB>
[no completion]

note that the inverse is also true: trying to quote an attribute will never consider attribute names that don't need to be quoted:

nix-repl> a."til<TAB>
nix-repl> a."tiler@crazy"

Expected behavior

at the very least, the repl should show that the attribute exists, instead of acting like there's nothing that starts with "tiler" in the attrset. same goes for the opposite direction: "tilix" should be a candidate completion for a."til<TAB>.

since quoting an attribute name is always valid, the repl could quote the entire prefix if there is a quoted name in the completions, though i'm not sure how much AST wrangling that might involve? idk how the completion system works yet.

nix --version output

nix (Lix, like Nix) 2.95.1
System type: x86_64-linux
Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/courvoie/.config/nix/nix.conf:/etc/xdg/xdg-ubuntu-xorg/nix/nix.conf:/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/slkbw0cg08jhfsax6kc0bf6rvw7rkl26-lix-2.95.1/share

Additional context

for context, i was trying to find "tiling-assistant@leleat-on-github" in nixpkgs's pkgs.gnome46Extensions by searching for gnome46Extensions.tiling-a<TAB> (since pkgs.gnomeExtensions names it simply tiling-assistant, which doesn't need to be quoted), but nothing was coming up, so i thought it just didn't exist :| then i tried attrNames gnome46Extensions and manually scrolled to find it.

## Describe the bug trying to tab-complete an attribute name that needs to be quoted doesn't work if the user doesn't already know it needs to be quoted. tt also isn't considered for completion if there is another attribute with an identical prefix that _doesn't_ need to be quoted. ## Steps To Reproduce ``` nix-repl> a = { "tiler@crazy" = 5; tilix = 4; } nix-repl> a.til<TAB> nix-repl> a.tilix nix-repl> a.tiler<TAB> [no completion] ``` note that the inverse is also true: trying to quote an attribute will never consider attribute names that don't _need_ to be quoted: ``` nix-repl> a."til<TAB> nix-repl> a."tiler@crazy" ``` ## Expected behavior at the very least, the repl should _show_ that the attribute exists, instead of acting like there's nothing that starts with "tiler" in the attrset. same goes for the opposite direction: `"tilix"` should be a candidate completion for `a."til<TAB>`. since quoting an attribute name is always valid, the repl could quote the entire prefix if there is a quoted name in the completions, though i'm not sure how much AST wrangling that might involve? idk how the completion system works yet. ## `nix --version` output ``` nix (Lix, like Nix) 2.95.1 System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/courvoie/.config/nix/nix.conf:/etc/xdg/xdg-ubuntu-xorg/nix/nix.conf:/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/slkbw0cg08jhfsax6kc0bf6rvw7rkl26-lix-2.95.1/share ``` ## Additional context for context, i was trying to find "tiling-assistant@leleat-on-github" in nixpkgs's `pkgs.gnome46Extensions` by searching for `gnome46Extensions.tiling-a<TAB>` (since `pkgs.gnomeExtensions` names it simply `tiling-assistant`, which doesn't need to be quoted), but nothing was coming up, so i thought it just didn't exist :| then i tried `attrNames gnome46Extensions` and manually scrolled to find it.
Owner

looks like https://git.lix.systems/lix-project/lix/src/branch/main/lix/libcmd/repl.cc#L532 should check from 1 instead of 0 if the character at 0 is a "

looks like https://git.lix.systems/lix-project/lix/src/branch/main/lix/libcmd/repl.cc#L532 should check from `1` instead of `0` if the character at `0` is a `"`
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/5515 ("libcmd/repl: better quoted attrs completion")
  • commit message in cl/5534 ("libcmd/repl: use replxx as line editing library")
  • comment in cl/5534 ("libcmd/repl: use replxx as line editing library")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/5515", "number": 5515, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5534", "number": 5534, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5534", "number": 5534, "kind": "comment"}], "cl_meta": {"5515": {"change_title": "libcmd/repl: better quoted attrs completion"}, "5534": {"change_title": "libcmd/repl: use replxx as line editing library"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/5515](https://gerrit.lix.systems/c/lix/+/5515) ("libcmd/repl: better quoted attrs completion") * commit message in [cl/5534](https://gerrit.lix.systems/c/lix/+/5534) ("libcmd/repl: use replxx as line editing library") * comment in [cl/5534](https://gerrit.lix.systems/c/lix/+/5534) ("libcmd/repl: use replxx as line editing library")
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#1193
No description provided.