antonmedv / fx

Terminal JSON viewer & processor
https://fx.wtf
MIT License
19.08k stars 438 forks source link

In interactive mode, move cursor to search matches when at end of JSON #111

Closed VimCommando closed 5 years ago

VimCommando commented 5 years ago

Right now if you search for a term, all the hits will highlight, and the screen scrolls to put the first hit at the top of the screen. When there is not enough JSON left, the cursor does not move own from the top of the screen to the highlighted term.

This means if you are searching for a term, and want to expand the JSON at the term hit, you have to manually scroll the cursor down do the hit first. When using keyboard navigation, this defeats the purpose of searching to save time.

antonmedv commented 5 years ago

Can you give me an example to better understand?

VimCommando commented 5 years ago

Absolutely. Lets start with a standard 25x80 shell just for consistency, and open a long .json file (I've attached the one I created for testing.)

image

Now use / to search for zulu. The zulu element will highlight and expand.

image

Next I want to expand the colors element we just exposed from searching zulu. Because Zulu is highlighted and expanded, I expect the cursor to be there. So I press j and l to move down one line and expand colors.

image

But the cursor was not there, it instead expands the quebec element at the top of the screen. If you repeat this for an element near the top of the screen, like searching for echo the result is much less noticeable because the search result ends up as the second line.

image

So if you are exploring an unfamiliar JSON structure, this slows you down.

And a couple references from other Linux tools.

image image
antonmedv commented 5 years ago

Done! I've implemented it. See https://github.com/antonmedv/fx/releases/tag/14.1.0

VimCommando commented 5 years ago

That is awesome 🎉

Thank you!