dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
21.82k stars 364 forks source link

🚀 Option to skip hunks when `--navigate`-ing #1500

Open tleb opened 1 year ago

tleb commented 1 year ago

Hi,

Using --navigate, I'd like for n and N to bring me to the next and previous files respectively. Would you accept such a feature? If it is yes, what shape should it take: a flag, a feature, something else?

That feature would only apply when --navigate-regex is not used, ie when the regex is the default value.

Here is a minimal patch that implements the change without looking at any flag. The constant false should be replaced by a conditional from flags or such. I've not modified the value of hunk_label as it gets passed after that to the config (and apparently is used elsewhere).

diff --git a/src/config.rs b/src/config.rs
index cab21eb..ec2d064 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -239,7 +239,7 @@ impl From<cli::Opt> for Config {
                 &file_added_label,
                 &file_removed_label,
                 &file_renamed_label,
-                &hunk_label,
+                if false { &hunk_label } else { "" },
             ))
         } else {
             opt.navigate_regex

By the way, thanks for the Makefile. First change to a Rust project and I had the nice surprise of it compiling fully with a make which I typed out of habit. I did not read any doc. So great first contributor experience!