liuchengxu / vim-which-key

:tulip: Vim plugin that shows keybindings in popup
https://liuchengxu.github.io/vim-which-key/
MIT License
1.93k stars 66 forks source link

Vim window become blank after resize when which-key is active #27

Open jiaming-shi opened 5 years ago

jiaming-shi commented 5 years ago

If you think it's a bug, please provide a minimal vimrc to reproduce:

call plug#begin('~/.config/nvim/plugged')
Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }
call plug#end()

let mapleader = ' '
let maplocalleader = '\'

augroup vimrc
  autocmd!
  autocmd! User vim-which-key call which_key#register('<Space>', 'g:which_key_map')
  autocmd! FileType which_key
  autocmd  FileType which_key set laststatus=0
    \| autocmd BufLeave <buffer> set laststatus=2
augroup END

" ----------------------------------------------------------------------------
" vim-which-key
" ----------------------------------------------------------------------------
nnoremap <silent> <leader>      :<c-u>WhichKey '<Space>'<CR>
vnoremap <silent> <leader>      :<c-u>WhichKeyVisual '<Space>'<CR>
nnoremap <silent> <localleader> :<c-u>WhichKey '\'<CR>
let g:which_key_map = {}
let g:which_key_map.2 = 'which_key_ignore'
let g:which_key_map.3 = 'which_key_ignore'
let g:which_key_map.4 = 'which_key_ignore'
let g:which_key_map.5 = 'which_key_ignore'
let g:which_key_map.6 = 'which_key_ignore'
let g:which_key_map.7 = 'which_key_ignore'
let g:which_key_map.8 = 'which_key_ignore'
let g:which_key_map.9 = 'which_key_ignore'
let g:which_key_map.b = {
      \ 'name' : '+buffer' ,
      \ '1' : ['b1'        , 'buffer 1']        ,
      \ '2' : ['b2'        , 'buffer 2']        ,
      \ 'd' : ['bd'        , 'delete-buffer']   ,
      \ 'f' : ['bfirst'    , 'first-buffer']    ,
      \ 'h' : ['Startify'  , 'home-buffer']     ,
      \ 'l' : ['blast'     , 'last-buffer']     ,
      \ 'n' : ['bnext'     , 'next-buffer']     ,
      \ 'p' : ['bprevious' , 'previous-buffer'] ,
      \ '?' : ['Buffers'   , 'fzf-buffer']      ,
      \ }

Problem Description

If I press <Space> to active which-key, then resize neovim pane size in tmux, the neovim pane become blank until I press <ESC> to quit which-key or complete some mapping in which-key table.

image image

liuchengxu commented 5 years ago

Thanks for the report. Please see if this branch fixes this issue.

jiaming-shi commented 5 years ago

Thanks for the quick fix, it basically works, but still have some problems.

Scene 1

In addition, if I did not complete a mapping in which-key in the first step, then pressing any key in the second step has no effect, the whole interface is stuck, I can only kill the neovim process to quit. If I have done a mapping in the first step, then in the second step, when I complete a mapping again, the window will become blank, image then by pressing esc or other keys, the contents of the window will be refreshed, but the size is the first step size not fullscreen size. image

Scene 2

After these three steps, I will encounter the same problem in scene 1.

liuchengxu commented 5 years ago

Confirmed. After some investigation, I found it's probably getchar() that somehow leads to the VimResized event not triggered. It may not be that easy to figure this out, so currently there is not any workaround for this issue. Sorry about that and I'll keep looking for a solution.

jiaming-shi commented 5 years ago

Thank you for your prompt reply, the scenes I mentioned are not common usage cases, so it will not affect the normal use of this plugin, and I will also try to find a solution.