Skip to content

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

Description

@your-diary
  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"
        }
    ]
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions