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

fzf doesn't open file in normal mode (gvim/windows) #1169

Closed
3 of 15 tasks
ghost opened this issue Dec 2, 2017 · 16 comments
Closed
3 of 15 tasks

fzf doesn't open file in normal mode (gvim/windows) #1169

ghost opened this issue Dec 2, 2017 · 16 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Dec 2, 2017

  • Category
    • fzf binary
    • fzf-tmux script
    • Key bindings
    • Completion
    • Vim
    • Neovim
    • Etc.
  • OS
    • Linux
    • Mac OS X
    • Windows
    • Windows Subsystem for Linux
    • Etc.
  • Shell
    • bash
    • zsh
    • fish

Environment: gvim8 patch 1-1358 / windows 10, compiled with +terminal.

The issue: I have always press double <ESC> to exit something unclear to bring to normal mode in vim after select a file to open from fzf. Video demo.

I think terminal didn't exit properly so I asked in vim here. I try to solve the issue by searching through fzf codebase but silly me I can't find anything.

@ghost
Copy link
Author

ghost commented Dec 2, 2017

The same result with only fzf plugin enabled:
gvim.exe -u NONE --cmd "set nocp | set rtp+=~/vimfiles/pack/plugins/start/fzf | runtime! plugin/fzf.vim"

@junegunn
Copy link
Owner

junegunn commented Dec 3, 2017

Since gdamore/tcell#159 (#1093 (comment)) is now merged, I'll rebuild Windows binary with the updated tcell and see if it helps.

@junegunn
Copy link
Owner

junegunn commented Dec 3, 2017

I can't reproduce ending up in insert mode, but I do need to press enter again to finish fzf process.

Updating tcell to the latest didn't help

EDIT: Wait a minute, I might have missed something, let me check again.

@ghost
Copy link
Author

ghost commented Dec 3, 2017

It's not actually end up with insert mode but it didn't exit terminal cleanly. Right after open file I can type characters into buffer. Thanks for looking into this issue.

@junegunn
Copy link
Owner

junegunn commented Dec 3, 2017

I have confirmed that the extra-enter problem is fixed with updated tcell. You can download the following alpha binary and test it.

https://github.com/junegunn/fzf-bin/releases/download/alpha/fzf-0.17.2-alpha-windows_amd64.zip

I first built fzf with the latest revision of tcell, but it didn't even run, panicking, so I had to update only to the point where the patch is merged, and all seemed fine.

@junegunn junegunn added this to the 0.17.2 milestone Dec 3, 2017
@ghost
Copy link
Author

ghost commented Dec 3, 2017

Thanks. Do you notice that we have a gap between opened buffer and title of it? It keeps the title !cmd.exe for a while before change it to opened file.

If I have this setup in minimal vimrc: autocmd VimEnter * silent! :History<CR>, the issue persist. Means the fix somehow happens after autocmd run.

@janlazo
Copy link
Contributor

janlazo commented Dec 4, 2017

After FZF finishes execution on GVim, entering any key reverts the title to what it was before running FZF, or History in your autocmd. It's likely a lazy window update. IIRC, the Vim plugin doesn't modify titlestring or set the term_name in the Vim terminal options.

@ghost
Copy link
Author

ghost commented Dec 4, 2017

@janlazo : Is there a way to make it faster to update? Should I open a ticket in vim?
Can you confirm the issue still happens with this setup?
Minimal vimrc:
autocmd VimEnter * silent! :History<CR>

  • Run this command in cmd under user directory:
    gvim.exe --cmd "set nocp | set rtp+=~/vimfiles/pack/plugins/start/fzf | runtime! plugin/fzf.vim"
  • Open an arbitrary file then type something right after open the file. You'll see that characters put into the file. We expect it should open the file in normal mode.

@janlazo
Copy link
Contributor

janlazo commented Dec 5, 2017

call term_start('cmd', {'curwin': v:true, 'term_finish': 'close'})

acts like :terminal ++close and should force the update. It works for me on 8.0.1358.
In the Vim plugin, the exit callback must be updated since ++close doesn't apply to Neovim.

If this doesn't work, try :normal and feed any hjkl movement characters. redraw!

function! fzf.on_exit(id, code, ...)
  if !has('nvim') && has('gui_running')
    redraw!
  endif
endfunction

janlazo added a commit to janlazo/fzf that referenced this issue Dec 5, 2017
Related: junegunn#1169

Title of current window does not update after the terminal buffer closes.
Passing `term_finish: 'close'` to terminal options doesn't work
because `curwin` is set.
Force a screen update with `redraw!` which affects the window title(?).
This screen update is not required in Neovim.

Patch tested on GVim 8.0.1358
janlazo added a commit to janlazo/fzf that referenced this issue Dec 5, 2017
Related: junegunn#1169

Title of current window does not update after the terminal buffer closes.
Passing `term_finish: 'close'` to terminal options doesn't work
because `curwin` is set.
Force a screen update with `redraw!` which affects the window title(?).
This screen update is not required in Neovim.

Patch tested on GVim 8.0.1358
@ghost
Copy link
Author

ghost commented Dec 5, 2017

Thanks, your PR fixed title update issue.
But the issue about normal mode still happens #1169 (comment)

@janlazo
Copy link
Contributor

janlazo commented Dec 5, 2017

I can reproduce the normal mode issue with your autocmd but I don't know why it happens.

@ghost
Copy link
Author

ghost commented Dec 6, 2017

Thanks, I have to stop invoke :History at vim startup. Hope this issue be fixed soon. If possible please open the issue so someone may has solution for it.

@ghost
Copy link
Author

ghost commented Dec 6, 2017

The normal open issue with autocmd persist with version fzf 0.17.3.

@junegunn
Copy link
Owner

junegunn commented Dec 6, 2017

I don't have access to a Windows machine now, so I'm not sure, but does this help?

autocmd VimEnter * silent! :redraw! | History<CR>

And you mean it only happens when you trigger the command on VimEnter event?

@ghost
Copy link
Author

ghost commented Dec 6, 2017

Sorry but it doesn't fix the issue.
Yes, I have another map that trigger manually after vim started: nnoremap <silent> <leader>s :History<CR> and it didn't have normal issue, :History also doesn't have normal issue.

@ghost
Copy link
Author

ghost commented Dec 8, 2017

I've noticed something that maybe help on this. I can produce a weird behavior happens when issue commands :History or :FZF then press <C-c> two times, it will produce a message:
Type :qa! and press <Enter> to abandon all changes and exit Vim
The expected behavior should be press <C-c> one time and fall back to current buffer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants