roosta / tmux-fuzzback

Search your tmux scrollback buffer using fuzzy matching
Other
140 stars 5 forks source link

FZF preview scrollback #6

Closed cibinmathew closed 2 years ago

cibinmathew commented 2 years ago

Thanks @roosta for this wonderful plugin.

Feature Request Just wanted to check if it is possible to add a preview(with context) of the focussed line in the fzf matches. This will help to read the neighbouring lines as well.

roosta commented 2 years ago

Glad you like it! I can set that up. This month has been a bit busy for me, trying to juggle a lot of things but as soon as things settle down I'll look into this as well as #5

roosta commented 2 years ago

Hello again, now I've made a preview feature branch, that is mostly working. An issue is running it from vim, or any other terminal application like that. That's been an issue with fuzzback in general, and is a bit tricky to deal with, but as far as your usual scrollback goes it should work.

Mind giving the branch a whirl, and letting me know how that goes?

cibinmathew commented 2 years ago

@roosta Thanks for adding the feature. I will try to set this up and will update here in couple of days.

cibinmathew commented 2 years ago

I will keep adding the observations below

  1. Preview is scrollable for some matches but not for others. Preview of any match should ideally contain the same number of lines as in the scrollback buffer
  2. Preview lines getting wrapped(So any longer line becomes 2 lines) - This could be because of fzf border. I will give a try tweaking default opts
roosta commented 2 years ago

Thanks for your thoughts

  1. That it is scrollable at all is probably a bug, I center the relevant line using sed, cropping the text. I don't really see the point of letting users scroll through the whole scrollback with preview, it is a preview after all.
  2. Hmm, yeah I see what you mean. Not sure how to deal with that though, like you said possibly a fzf setting.

As a side note, I did find that using popup and a 90% size worked really well with the preview. EDIT: Clarification

cibinmathew commented 2 years ago

I gave a try in tweaking fzf settings

  1. It was scrollable because the lines were getting wrapped when line ouccupied 100% due to right justification(screenshot) or whenever it has full line content image

  2. It was okay with below settings. Do you mind adding this to tmux-fuzzback/scripts/fuzzback.sh --preview-window=border-none

roosta commented 2 years ago

Thanks for looking into this, appreciate it. I'll add that option right away.

roosta commented 2 years ago

hmm, I'm not sure that option is ideal. It makes the preview and search look very similar. I don't have a wrapping issue myself, I tried in vim: image Seems it just renders the line there without wrapping.

roosta commented 2 years ago

Could it be a pager setting maybe? what pager are you using? EDIT: Probably not...

cibinmathew commented 2 years ago

Could be related to local FZF defaults. But we can proceed with the merge as it is not a stopper.

roosta commented 2 years ago

Think I found a way that works. Give it a try now. While investigating my local options I stumbled upon an option in fzf manual

---preview-window=nowrap
roosta commented 2 years ago

I think that forcing nowrap in fuzzback makes most sense Also I cant merge yet, there is an issue with preview in terminal applications like vim, preview gets all loopy. I wanted to fix that before merge.

cibinmathew commented 2 years ago

Think I found a way that works. Give it a try now. While investigating my local options I stumbled upon an option in fzf manual

---preview-window=nowrap

Observations: ---preview-window=nowrap : No line wrapping but some are still scrollable (lines in the preview 5) This one in screenshot is scrolllable image

--preview-window=nowrap,border-top : No line wrapping but some are still scrollable (strangely this feeds in 7 lines into the buffer and not 5)

--preview-window=nowrap,border-none: Works perfectly but preview window is not distinguishable like you mentioned :-(

cibinmathew commented 2 years ago

@roosta we can proceed on the above options like you mentioned for now and revisit if something better is discovered on more usage

roosta commented 2 years ago

I might be able to fix the scrolling issue else where, I can modify the sed call. It is a bit of a strange bug though, it will only happen sometimes for me, not sure what is the cause yet. Have you been able to consistently reproduce it?

cibinmathew commented 2 years ago

No identifiable pattern yet :-(

tru2dagame commented 2 years ago

Hi guys, I have tried the feat/preview branch. It works very well for me. Maybe we could add a toggle keybinding to toggle the preview.

roosta commented 2 years ago

Hi @tru2dagame This feature is 90% complete, just a few tweaks needed but I got sidetracked for a while. I'm using this branch myself, and it works fine most of the time, feel free to do the same. Once I fix a couple of bugs I'll merge.

Ctrl-p is currently mapped to preview toggle, which I think is the default in fzf, I can setup an option for a custom one of you'd like.

roosta commented 2 years ago

Seem the issue I was holding off on fixed itself with a fzf update, so time to merge.