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

Any way to disrespect an incomplete jq expression being typed and fall back to the longest valid prefix? #63

Open
your-diary opened this issue Dec 1, 2024 · 0 comments

Comments

@your-diary
Copy link

  1. I have this original JSON:

    trimmed_1

  2. When I type .results[], jnv correctly filters the results:

    trimmed_2

  3. Then, if I additionally type some string, it seems jnv tries to evaluate the entire input text as a jq expression, completely reverting the filtering. This is extremely annoying because the input text being typed is of course generally an incomplete jq expression:

    trimmed_3

  4. When I complete typing the expression, jnv again succeeds to evaluate the expression:

    trimmed_4

Question

Is it possible to disrespect (i.e. ignore) an incomplete jq expression being typed and instead fall back to the longest valid prefix?

For example:

input text longest valid prefix
.results[] .results[]
.results[] | .results[]
.results[] | select .results[]
.results[] | select(.type == .results[]
.results[] | select(.type == "type1" .results[]
.results[] | select(.type == "type1") .results[] | select(.type == "type1")

Original JSON

{
    "results": [
        {
            "type": "type1",
            "value": "value1"
        },
        {
            "type": "type1",
            "value": "value2"
        },
        {
            "type": "type2",
            "value": "value3"
        }
    ]
}

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

No branches or pull requests

1 participant