Canop / broot

A new way to see and navigate directory trees : https://dystroy.org/broot
MIT License
10.35k stars 226 forks source link

optionally show lines surrounding a match in preview #866

Closed Canop closed 3 months ago

Canop commented 3 months ago

New settings:

###############################################################
# lines around matching line in filtered preview
#
# When searching the content of a file, you can have either
# only the matching lines displayed, or some of the surrounding
# ones too.
#
lines_before_match_in_preview: 1
lines_after_match_in_preview: 1

Fix #756

stevenxxiu commented 3 months ago

Thanks for this. Could there be a horizontal line break of sorts, between search results that aren't next to each other?

Canop commented 3 months ago

It's possible: image

Now I have a bunch of things to check, and also to update the doc for the skin entry, and modify all skins...

Canop commented 3 months ago

Can you check if everything looks right ?

note: there's no separator when lines_before and lines_after are 0, to keep it dense.

stevenxxiu commented 3 months ago

Thanks! Looks good to me.

Canop commented 3 months ago

I need to support the tab to go to next match

Canop commented 3 months ago

Done. Now you can go to next match with tab and the previous one with shift-tab (with default bindings).

This is needed since the down and arrow keys don't jump to the next/previous matching line.

Canop commented 3 months ago

Question is... Should I set lines_before_match_in_preview and lines_after_match_in_preview to 0 or 1 by default ?

stevenxxiu commented 3 months ago

Up to you I suppose.

Ripgrep itself doesn't enable this by default.

Setting this to 0 will keep the previous behavior, and 1 will help people notice this feature.

Personally I set this to 2.