Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content is cut off with fzf#vim#with_preview #751

Closed
4 of 9 tasks
npearson72 opened this issue Jan 7, 2019 · 13 comments · Fixed by #1078
Closed
4 of 9 tasks

Content is cut off with fzf#vim#with_preview #751

npearson72 opened this issue Jan 7, 2019 · 13 comments · Fixed by #1078

Comments

@npearson72
Copy link

npearson72 commented Jan 7, 2019

  • Category
    • Question
    • Bug
    • Suggestion
  • OS
    • Linux
    • macOS
    • Windows
    • Etc.
  • Vim
    • Vim
    • Neovim

I'm using the following configs:

set nocompatible hidden laststatus=2

if !filereadable('/tmp/plug.vim')
  silent !curl --insecure -fLo /tmp/plug.vim
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
endif

source /tmp/plug.vim
call plug#begin('/tmp/plugged')
Plug 'junegunn/fzf', { 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
call plug#end()

autocmd VimEnter * PlugClean! | PlugUpdate --sync

" Below is what I've added to my configs:
nnoremap <c-p> :Files<cr>
command! -bang -nargs=? -complete=dir Files
  \ call fzf#vim#files(<q-args>, fzf#vim#with_preview('right:50%', 'ctrl-p'), <bang>0)

After invoking Ctrl+p I'm presented with a list of my files with a preview window. However the lines of content in the preview is limited to ~19, when in actuality the files have more lines.

kapture 2019-01-07 at 10 23 59

@lan-nguyen91
Copy link

I got same behavior on Mac with vim8, did you find a fix yet @npearson72 ?

@npearson72
Copy link
Author

@lan-nguyen91 afraid not.

@lan-nguyen91
Copy link

@junegunn, do you happen to know if vim default config hide stuff on preview window, right now the first 30 lines show on my set up, but as I scrolled, it is all blank. :(

@junegunn
Copy link
Owner

The behavior is intentional and is not configurable: https://github.com/junegunn/fzf.vim/blob/master/bin/preview.sh#L50-L54

For now, I suggest that you fork the repository and change it to your needs since I'm not planning to add more configuration options for the time being.

@lan-nguyen91
Copy link

@junegunn thanks for the direction, @npearson72 I followed June direction, and removed this condition && NR <= $LAST in the line above, i'm not sure it is ideal but works for me right now. Cheers 😀

@npearson72
Copy link
Author

Works like a charm. Thanks guys!

@ogirginc
Copy link

Removing && NR <= $LAST from preview.sh file does not seem to work anymore.

I ended up with these changes:

  • Commented out this if.
# if [ -z "$FZF_PREVIEW_COMMAND" ] && command -v bat > /dev/null; then
#   bat --style=numbers --color=always --pager=never \
#       --line-range=$FIRST:$LAST --highlight-line=$CENTER "$FILE"
#   exit $?
# fi
  • Add bat back.
DEFAULT_COMMAND="bat --style=numbers --color=always {} || highlight -O ansi -l {} || coderay {} || rougify {} || cat {}"
CMD=${FZF_PREVIEW_COMMAND:-$DEFAULT_COMMAND}
CMD=${CMD//{\}/$(printf %q "$FILE")}
eval "$CMD" 2> /dev/null | awk "NR >= $FIRST { \
    if (NR == $CENTER) \
        { gsub(/\x1b[[0-9;]*m/, \"&$REVERSE\"); printf(\"$REVERSE%s\n$RESET\", \$0); } \
    else printf(\"$RESET%s\n\", \$0); \
    }"

@kuntau
Copy link

kuntau commented Mar 3, 2020

How do you scroll the preview pane? 🤔

@her
Copy link

her commented May 26, 2020

Easiest way for me to hack around this was to set

FIRST=0
LAST=1000000

@junegunn Why do we limit the file preview?

@Rodrigo-Barros
Copy link

Rodrigo-Barros commented Jun 21, 2020

How do you scroll the preview pane? thinking

Just use shift + down or shift +up,
mouse scroll works too.

@her
Copy link

her commented Jun 22, 2020

@Rodrigo-Barros the content is not all there though, it's cut off. Preview a large file and scroll, you'll see you only have a small subsection of the file, rather than all the contents.

junegunn added a commit that referenced this issue Aug 12, 2020
This allows you to scroll upwards

Fix #1053
Fix #751
Fix #749
junegunn added a commit that referenced this issue Aug 12, 2020
This allows you to scroll upwards

Fix #1053
Fix #751
Fix #749
@123subhadeep
Copy link

@ogirginc @Rodrigo-Barros

Do any of you know how I can keep the highlighted line in the preview in the middle by default. Right now, it always shows 5 lines above the highlighted line, which isn't helpful to get context before the highlighted line. #1092 has a screenshot with an example.

Another question for you guys, I saw that Shift + Up/Down works great with scrolling, is it possible to rebind those keys ? Arrow keys are harder to reach (Would prefer something like Ctrl -j/k).

Looking forward to hearing from you. Thanks in advance.

@Rodrigo-Barros
Copy link

Rodrigo-Barros commented Aug 19, 2020

@123subhadeep you can install bat it's an optional dependency that enables syntax highlight.
you can add this line on your .vimrc to rebind your keys:
let $FZF_DEFAULT_OPTS='--bind=ctrl-j:preview-down,ctrl-k:preview-up'

This info available on manual.
suggested topics to view more info AVAILABLE KEYBINDS, AVAILABLE ACTIONS

I don't know if there another way to rebind your keys.

antoinemadec pushed a commit to antoinemadec/fzf.vim that referenced this issue Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants