which-key.nvim icon indicating copy to clipboard operation
which-key.nvim copied to clipboard

fix: fix #301

Open xiyaowong opened this issue 1 year ago • 9 comments

xiyaowong avatar Jul 03 '22 01:07 xiyaowong

Just curious, what’s this echo used for?

registerGen avatar Jul 03 '22 03:07 registerGen

Tested around a bit and works fine for me without vim.cmd [[echon ""]]

Is there a reason to keep that dummy output?

jemag avatar Jul 03 '22 03:07 jemag

I think it is used for clear current command line. It is not needed for cmdheight=0 though.

Shougo avatar Jul 03 '22 03:07 Shougo

I think it is used for clear current command line. It is not needed for cmdheight=0 though.

echon works well no matter what the value of cmdheight is, I don't think it's necessary to add a check for cmdheight, just keep it simple

xiyaowong avatar Jul 03 '22 05:07 xiyaowong

@registerGen @jemag It's used to clear the input context https://github.com/folke/which-key.nvim/blob/bd4411a2ed4dd8bb69c125e339d837028a6eea71/lua/which-key/layout.lua#L89

xiyaowong avatar Jul 03 '22 05:07 xiyaowong

image this also works

@Shougo echo will definitely cause waiting for enter, is it expected?

xiyaowong avatar Jul 03 '22 05:07 xiyaowong

@Shougo echo will definitely cause waiting for enter, is it expected?

It is expected. Because you have not command line area. Please see cmdheight description.

						*'cmdheight'* *'ch'*
'cmdheight' 'ch'	number	(default 1)
			global
	Number of screen lines to use for the command-line.  Helps avoiding
	|hit-enter| prompts.
	The value of this option is stored with the tab page, so that each tab
	page can have a different value.

	When 'cmdheight' is zero, it disables echo area and all outputs need
	|hit-enter| prompt.

Shougo avatar Jul 03 '22 06:07 Shougo

@Shougo Oh, I forgot to read the help about cmdheight, thanks for the tip

xiyaowong avatar Jul 03 '22 08:07 xiyaowong

This also affects gq

For those affected, if you prefer not to install the fork branch, you can dynamically patch which-key while we wait for review and merge:

put this somewhere in your config, I put it in the bottom of the file which calls wk.setup

---PATCH from https://github.com/folke/which-key.nvim/pull/305
local wk_view = require 'which-key.view'
wk_view.hide = function()
  vim.api.nvim_echo({ { "" } }, false, {})
  vim.cmd 'redraw'
  wk_view.hide_cursor()
  if wk_view.buf and vim.api.nvim_buf_is_valid(wk_view.buf) then
    vim.api.nvim_buf_delete(wk_view.buf, { force = true })
    wk_view.buf = nil
  end
  if wk_view.win and vim.api.nvim_win_is_valid(wk_view.win) then
    vim.api.nvim_win_close(wk_view.win, { force = true })
    wk_view.win = nil
  end
end
---ENDPATCH

bennypowers avatar Jul 05 '22 10:07 bennypowers