facelessuser / Rummage

Rummage is a GUI for grep like searches in Python
https://facelessuser.github.io/Rummage/
MIT License
74 stars 10 forks source link

Whole-file preview #439

Open Jackenmen opened 1 year ago

Jackenmen commented 1 year ago

Have you considered adding a whole-file preview to this application? In the past when I was using Windows as my main OS, I was using dnGrep as a GUI for grep-like searching and one very cool feature that I couldn't really find in any alternative that's available for Linux is the whole-file preview.

In dnGrep, on the bottom left side of the window, there's a list of all search matches. They are grouped by file, and for each match, a few lines of context are shown around it. Additionally, you can also see a whole-file preview on the right side of the window. image

I personally found that having these preview features made me want to use the GUI more often than CLI where I would only get a hard-to-digest long list of matched lines, at best with few context lines around it if I used -A or -B option with it.

facelessuser commented 1 year ago

I've considered it before, at least to some extent, but it's never been a dire need for me. If I want to get context, I usually double-click the entry and it opens in my editor quite fast. We already do things like truncate lines if they are very long to limit how much content we are storing in memory, and while there is some logic in the core that allows for capturing more context, I ended up not using it in order to store less and not waste time acquiring additional lines of context. Python is not the fastest language, so the less we do, the quicker things go.

Could we allow a quick preview directly within Rummage? Maybe. If we kept the line info around (like where lines end) I could see maybe a shortcut to preview a line with more context where we dynamically seek the lines and display them on demand. The same could be done for a full preview. As we already have all the info related to where the matches are, we could, on-demand load up a view of a file's content and highlight the matches.

It's something to think about at least assuming I had the time to dig into it. FWIW, Rummage generally provides enough for me to be productive, but that doesn't mean there isn't room for improvement. While I can't promise we'll implement this feature, if I have time, I may look into what's possible in the future.