Code Monkey home page Code Monkey logo

Comments (4)

jasonmobley avatar jasonmobley commented on June 12, 2024

Seeing the same in delta 0.17.0

from delta.

sadamczyk avatar sadamczyk commented on June 12, 2024

I'm a bit annoyed by this as well. Jumping to the next hunk is usually such a small jump that scrolling with Ctrl+D/U already is more than good enough. And it's especially annoying with large files like lock files.

But this behavior is documented in the Features list of the README.md (even though it's missing from the docs):

n and N keybindings to move between files in large diffs, and between diffs in log -p views (--navigate)

There are 2 options to fix this:

  1. Set --hunk-label "" to an empty string. Or via ~/.gitconfig: hunk-label = (just nothing).
    This removes the β€’ from the beginning of every hunk, but that's totally fine for me. 🀷
  2. Set the --navigate-regex value to not search for the hunk labels.
    ~/.git/config: navigate-regex = ^(commit|added:|removed:|renamed:|Ξ”)
    But this assumes that you didn't change any of the configs that go into navigate-regex by default, like --file-added-label etc, since navigate-regex is actually built from all those options, see
    format!(
    "^(commit{}{}{}{}{})",
    optional_regexp(file_added_label),
    optional_regexp(file_removed_label),
    optional_regexp(file_renamed_label),
    optional_regexp(file_modified_label),
    optional_regexp(hunk_label),
    )

    So if you ever change any of these options, you'll need to manually change the navigate-regex option to reflect that as well. Otherwise this seems like the cleanest option.

from delta.

dandavison avatar dandavison commented on June 12, 2024

Just want to say that I sympathise with this! I also find that if I'm using navigate to jump, then by-hunk jumps often feel too small. So I'm open to interface design change proposals here.

A related variant is to increase our diff context, i.e. with git ... -U99 | delta or

[diff]
    context = 99

If we set that number large enough, then there are no within-file hunks any longer hence navigate jumps become by-file! Of course it can sometimes not be exactly what you want to have to scroll past large sections of unchanged content, but sometimes the lack of hunk breaks makes diffs easier to understand.

from delta.

sadamczyk avatar sadamczyk commented on June 12, 2024

@dandavison Good idea with setting a wider context. I'll definitely play around with increasing it a bit, even though 99 seems way too high for me personally. I'll set it to 9 and see how I like it, which will still reduce some hunks hopefully.

IMO The best way would be to have multiple search patterns, that you can search via different hotkeys.
For example something like n / N just for hunk jumps, c / C for commits, f / F for files etc.
That way the user can use whatever jumps make the most sense for their current use case.
But since delta uses plain old less, this isn't really possible afaik.

I could almost emulate this behavior with custom terminal hotkeys (I use WezTerm), so that my terminal inputs the correct search pattern for whatever navigation "mode" I want to use.
So for example pressing Ctrl+Shift+H could send the following key strokes to the terminal and therefore set less' search pattern to "hunks only": /^(β€’)↡ And then just use n/N as always.
And then have other hotkeys for other common navigation/search patterns I use.

from delta.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.