delta: 🐛 `--navigate` breaks `git log --oneline` and empty `git diff`

Clean repo and running git diff

image

Running git log --oneline gives same error.

Note that in both cases hitting Enter will make it print out the correct stuff (which makes #234 really obvious)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 17 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks @cben and @dandavison! Very clever! This fixes a long standing annoyance I had with git stash list.

Yep, this works great now. Thanks!

Oooh, here is a weird idea (which is maybe what you were getting at): don’t pass a pattern to less at all! Instead, append it to $HOME/.lesshst, then call less. Pressing <kbd>n</kbd> with no active pattern uses the last one from history 😜

This has several benefits when the diff is short, including --quit-if-one-screen compatibility, and not filling the screen _until you press <kbd>n</kbd> or <kbd>N</kbd>.

Simply appending doesn’t work; the format is not quite documented, need " before the pattern but there are few “sections” starting with . so it does’t always belong at the end (e.g. with --save-marks there may be .mark section after .search)… The file name also varies.

We could make less append it for us, something like:

echo 'guarantee a match: 123' | less --no-histdups --save-marks $'+/123\nq'

Normally that exits immediately with no visible output, but that’s an illusion — it wrote to the “alternate buffer” and switched back too fast to notice. Proof: echo $'\e[?47h' (switch to alt buffer without clearing). With --no-init, or terminal configs that don’t support/use alt buffer you’ll see that line plus a full screen of ~ ☹️. (This goes back to that StackExchange issue: less can’t search without painting the full screen.) And if I redirect > /dev/null, less won’t actually search (it’s in bypass cat-like mode), the history file is unaffected.

Don’t have time to play more with this now. This is promising, but also increasingly fragile and ideally needs explicit flags for the desired search behavior in less itself.