vim-which-key icon indicating copy to clipboard operation
vim-which-key copied to clipboard

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

Open jiaming-shi opened this issue 6 years ago • 4 comments

  • OS: Ubuntu 18.04

  • Vim: Neovim 0.3.1

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

jiaming-shi avatar Dec 31 '18 12:12 jiaming-shi

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

liuchengxu avatar Dec 31 '18 15:12 liuchengxu

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

Scene 1

  • step 1: If I open neovim in a small window, activate which-key, image
  • step 2: and then maximize the window, which-key is correctly re-arranged. image
  • step 3: But if I restore to the previous small window, which-key will maintain the layout in full screen state, will not rearrange, resulting in some content not visible. image

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

  • start in fullscreen
  • resize to a small size
  • return to fullscreen

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

jiaming-shi avatar Jan 01 '19 03:01 jiaming-shi

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.

liuchengxu avatar Jan 01 '19 11:01 liuchengxu

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.

jiaming-shi avatar Jan 02 '19 13:01 jiaming-shi