Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completeFlakeRefWithFragment: handle names with dots #11377

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ylh
Copy link
Contributor

@ylh ylh commented Aug 26, 2024

Motivation

remedies a FIXME:

nix build /etc/nixos#nixosConfigurations.w
# may now tab-complete to e.g.:
nix build /etc/nixos#nixosConfigurations.\"www.example.com\"

& subsequent completions into deeper attrpaths will preserve escaped quotes.

Context

{un,}escaping done in this PR errs on the side of simplicity to the point of being naïve (pretty easy to demonstrate that they are not strict inverses of each other), expectation being that tab completion is used interactively.

Priorities and Process

Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@ylh ylh requested a review from edolstra as a code owner August 26, 2024 13:31
@tomberek tomberek added the idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. label Aug 26, 2024
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-08-26-nix-team-meeting-minutes-172/51300/1

Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed in meeting today:
We think before we support this feature we should clean up the code a bit.

  • We should strive to have separate functions for quoting and unquoting (and ideally unit test that they round-trip). There might be something in libutil already to help with this (quoteStrings)
    • Maybe it needs to be a variation of what we have because of the potentially missing start/end quotes
    • Even if it's a variation, centralizing it makes sure that we don't duplicate code unnecessarily

src/libcmd/installables.cc Show resolved Hide resolved
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-08-28-nix-team-meeting-minutes-173/51302/1

@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label Aug 29, 2024
@ylh
Copy link
Contributor Author

ylh commented Aug 29, 2024

fair point as to the goto and tests in general; pushed accordingly—a bit confused as to what you mean by this, though:

We should strive to have separate functions for quoting and unquoting

as there already are, and they are in use here. namely, parseAttrPath and SymbolStr::operator<<. if you mean the backslash trickery alongside those calls, that is exclusive to the problem of shell completion, as is the function being patched here. emitting \" is about the most that can be done for the intersection of shells for which nix publishes completion hooks. the alternative would be to rewrite those hooks to communicate with nix in some canonical representation and escape/unescape on their end.

if you just mean the bit for detecting when a completion is taking place inside a quoted string, it would be possible, though of dubious utility, to add a variant of parseAttrPath with a special side-channel return to indicate EOF inside a quoted segment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. with-tests Issues related to testing. PRs with tests have some priority
Projects
Status: To triage
Development

Successfully merging this pull request may close these issues.

4 participants