200ok-ch/counsel-jq

Gives wrong results with `ivy-occur`

Gleek opened this issue · 5 comments

Gleek commented

ivy-occur can be used to get the filtered results in a separate buffer.
It is similar to the default action which opens up the result in *jq-json* buffer but instead uses an occur buffer.

This can help in filtering multiple json objects and compare the filtered results without having subsequent runs replace the results of previous ones.

Running ivy-occur (C-c C-o by default I think) opens up the full json object instead of only displaying the filtered results.

I'm unsure of what might be causing this or if this is a bug upstream in ivy.

munen commented

Hi @Gleek

Thanks for checking out counsel-jq!

Could you make a screencast showing what you're doing? I'm not a user of ivy-occur and don't understand how you compose it with counsel-jq from the description.

Gleek commented

Hello @munen,

Please see the screencast below. I first demo a sample run of ivy-occur on counsel-describe-variable function.
Running ivy-occur after some filtering returns the filtered results in a buffer.
Next I run counsel jq on a json and filter to a limited result. Running ivy-occur now does not retain the results, but instead shows the original json as is.

ivy-occur-counsel-jq.mp4
munen commented

Thank you for providing that screencast, I can see it now! 👍

I assume ivy-occur is a wrapper around occur and that there's state tracked somewhere inside of ivy. counsel-jq uses ivy and counsel for dynamically querying an external command (jq). If ivy does not implicitly track this state, I assume that it has to be tracked explicitly to be compatible with ivy-occur (or maybe less likely that it is a bug within ivy).

Are you interested in looking into this and creating a PR for it?

Gleek commented

I'll see if I can figure out something this weekend. 🙂

munen commented

Cool, looking forward to it^^