tmux-fuzzback icon indicating copy to clipboard operation
tmux-fuzzback copied to clipboard

FZF preview scrollback

Open cibinmathew opened this issue 2 years ago • 18 comments

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.

cibinmathew avatar Dec 13 '21 13:12 cibinmathew

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 avatar Dec 13 '21 13:12 roosta

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?

roosta avatar Jan 03 '22 16:01 roosta

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

cibinmathew avatar Jan 04 '22 18:01 cibinmathew

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

cibinmathew avatar Jan 05 '22 17:01 cibinmathew

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

roosta avatar Jan 05 '22 18:01 roosta

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

cibinmathew avatar Jan 12 '22 18:01 cibinmathew

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

roosta avatar Jan 13 '22 13:01 roosta

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 avatar Jan 13 '22 13:01 roosta

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

roosta avatar Jan 13 '22 13:01 roosta

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

cibinmathew avatar Jan 13 '22 14:01 cibinmathew

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 avatar Jan 13 '22 14:01 roosta

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.

roosta avatar Jan 13 '22 14:01 roosta

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 avatar Jan 15 '22 12:01 cibinmathew

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

cibinmathew avatar Jan 15 '22 12:01 cibinmathew

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?

roosta avatar Jan 15 '22 13:01 roosta

No identifiable pattern yet :-(

cibinmathew avatar Jan 16 '22 12:01 cibinmathew

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.

tru2dagame avatar May 04 '22 21:05 tru2dagame

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 avatar May 05 '22 08:05 roosta

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

roosta avatar Nov 15 '22 16:11 roosta