tig icon indicating copy to clipboard operation
tig copied to clipboard

Highlight search term in grep view

Open Vampire opened this issue 2 years ago • 8 comments

It would be nice if in the grep view the search term would be highlighted. Currently you have to first grep for asdf and then / for asdf in the grep view. Would be nice if the search term would immediately be highlighted like if searched or maybe better just with some other foreground color so that you can additionally search without confusion.

Vampire avatar Jun 08 '22 15:06 Vampire

When you run tig grep, the grep pattern is preloaded as the search pattern, you just have to press n to highlight all the occurrences.

koutcher avatar Jun 08 '22 17:06 koutcher

Besides that it would still be nice to have the search term highlighted independent of search so that you can search additionally, the functionality you describe seems to be broken. tig grep asdf followed by n says "No match found for 'bcec5204d788d56c7ba919c7b56cb0347a1dca0e'". which actually is the last commit I went to with :bcec5204d788d56c7ba919c7b56cb0347a1dca0e in the previous Tig session. If I do :q and then again tig grep asdf and then n it searches for occurrences of "q".

Vampire avatar Jun 08 '22 18:06 Vampire

And actually you would also need special handling for grep options in either case, I can thankfully at least do tig grep -i asdf or within running tig g followed by -i asdf to at least to the grep case-insensitively.

Vampire avatar Jun 08 '22 18:06 Vampire

My bad, the pattern is preloaded when doing tig -G or tig --grep but not tig grep. Taking grep options into account might be challenging...

koutcher avatar Jun 08 '22 19:06 koutcher

Hmm, ...

$ tig -G ersion
tig: No revisions match the given arguments.
$ tig --grep ersion
tig: No revisions match the given arguments.

Vampire avatar Jun 09 '22 15:06 Vampire

Tig does not implement the full command line parser of Git so you have to use tig -Gersion and tig --grep=ersion.

koutcher avatar Jun 09 '22 16:06 koutcher

Oh, I see. One more questions to that if you allow. Is there any chance you would enhance the command line parser to be more git-like? This difference feels a bit unexpected, especially if you are used to use spaces for the git command options. I don't see a feature request for that, would it make sense to open one or would you not consider it anyway?

Vampire avatar Jun 10 '22 08:06 Vampire

Honestly, no. While it does not implement the full command line parser of Git, Tig still has to triage the parameters to give to the Git commands only the one they accept. Allowing separate arguments would be much more complex and the benefit not worth the time spent to implement it.

koutcher avatar Jun 10 '22 17:06 koutcher