dandavison / delta

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

🐛 "navigate" makes less history transient #1261

Open adamchainz opened 1 year ago

adamchainz commented 1 year ago

237 changed delta to duplicate less’ history file before handing over. I find this surprising as it means one cannot recall searches from even previous delta invocations.

For example:

  1. Run git log through delta, search for specific commits with /^author: adam.
  2. Don't find intended commits, quit.
  3. Switch to the right branch.
  4. Run git log agani, type / then up-arrow to find past search - but it's not there.
  5. Have to type out /^author: adam accurately again.

I propose the implementation changes in one of two ways:

  1. Edit the user's default history file in-place to add the navigate search regex (or move to bottom). I didn’t spot the reason this option wasn’t taken previously. Editing the less history file just a bit doesn’t seem as bad as duplicating it.
  2. Duplicate the user’s less history file to ~/.local/share/delta/lesshst only if there isn’t a duplicate already. Otherwise, only edit the duplicate file, to append/move the navigate search string at/to the end.

Either option would make delta lesses share history. The first would share with other lesses, which is “less” of a win imo.

dandavison commented 1 year ago

Hi @adamchainz, thanks, although #237 was a big advance (being able to leave navigate activated and start using it without thinking), I've also been wanting to improve things so that my history is not lost.

Is this something you might be interested in working on? I haven't thought through the design options thoroughly, but I think one fixed premise I'd like to propose is that no non-delta less usage should ever see the automatically-generated delta regexps in less history.

I'm trying to remember the exact usage patterns that have bothered me. The one you describe certainly. I wonder whether I do in fact want delta less to share history with other less usage, much as if one had done git ... | delta | less. I'll watch my own usage.

cc @cben @Kr1ss-XD

adamchainz commented 1 year ago

non-delta less usage should ever see the automatically-generated delta regexps in less history.

Why stick to this? It's only one regexp. I don't think it's that troublesome to insert it into the normal less history.

Is this something you might be interested in working on?

Reviewing yes, but writing no, I don't have much Rust experience or time to pick it up.