junegunn / fzf.vim

fzf :heart: vim
MIT License
9.59k stars 582 forks source link

Is fzf#vim#buffer_commits not the same as invoking BCommits? #1354

Closed gennaro-tedesco closed 2 years ago

gennaro-tedesco commented 2 years ago

Is :call fzf#vim#buffer_commits() not the same as invoking :BCommits? In particular I noticed that the latter does not show the buffer commits at all (only the latest): see below reproducible example:

mkdir test
cd test
git init

echo "first" >> file
git add .
git commit -m "first"

echo "second" >> file
git add .
git commit -m "second"

then we see

https://user-images.githubusercontent.com/15387611/148083070-36961a99-3287-4162-a4cb-ecd9345bc02f.mov

namely BCommits shows all commits, fzf#vim#buffer_commits() does not. Apologies if this is trivially states somewhere I missed.

junegunn commented 2 years ago

It's a little complicated.

Here is the definition of :BCommits: https://github.com/junegunn/fzf.vim/blob/a4ce66d72508ce7c626dd7fe1ada9c3273fb5313/plugin/fzf.vim#L66

gennaro-tedesco commented 2 years ago

Apologies for re-opening an old and closed issue: I am currently using the definition of BCommits that you outlined above, namely

command! -bar -bang -range=% BCommits let b:fzf_winview = winsaveview() | <line1>,<line2>call fzf#vim#buffer_commits(fzf#vim#with_preview({'options': '--prompt "logs:"', 'down': '15'}), <bang>0)

and I would like to accompany it with a preview showing the patch of the selected commit. Whilst passing any argument to --preview=... (and actually even without specifying --preview=... at all) I see the exception

File not found <commit hash>

I suppose what happens is that fzf#vim#with_preview directly invokes the preview of the current file and at most replaces it with the content under the cursor (which in the example at hand are the buffer commit hashes). Notice that here I would like to explicitly pass a --preview to BCommits because otherwise I have let g:fzf_preview_window = [].

Similar issues

the former probably working with general options for preview, the latter should be the solution but it still does not work in my case.