Skip to content

Conversation

@xav-ie
Copy link
Contributor

@xav-ie xav-ie commented Nov 27, 2025


With the new completers stuff that recently came out, I tried to first use these recipes, but found they were sometimes not working... especially for nix commands when it runs into db error:

> carapace "nix" nushell ...["nix" "run" "nixpkgs#"] | from json | select value
───┬───────────────
 # │     value
───┼───────────────
 0"nixpkgs#ERR"
 1"nixpkgs#_"
───┴───────────────

If we try and apply documented recipe to the first element, it does not work:

> let spans = ["nix" "run" "nixpkgs#"]
> carapace "nix" nushell ...["nix" "run" $last_span] | from json | get value | first
"nixpkgs#ERR"
> (carapace $spans.0 nushell ...$spans | from json | get value | first) == $"($spans | last)ERR"
false

This is because the value literally includes the chars " at beginning at end. I am not sure exactly how it happens, but we could fix the recipe in this instance by wrapping the check with quotes.

> (carapace $spans.0 nushell ...$spans | from json | get value | first) == $"\"($spans | last)ERR\""
true

--but this is not very good for things like the cargo -1 example, which is not output with quotes. A more reliable solution is to use the display column. According to this code:
https://github.com/carapace-sh/carapace/blob/09b28a62d9ce4acbade91bc967cee173454407c1/internal/common/message.go#L92-L114

the display column will always at least start-with "ERR".

Therefore, let us update this example to be more robust and use a better heuristic :).


p.s. I hope to also add docs/examples for the new completion methods and stuffs after this :)

@xav-ie xav-ie marked this pull request as draft November 27, 2025 00:53
@xav-ie xav-ie marked this pull request as ready for review November 27, 2025 01:15
@fdncred fdncred merged commit 721a4e7 into nushell:main Nov 27, 2025
2 checks passed
@fdncred
Copy link
Contributor

fdncred commented Nov 27, 2025

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants