Skip to content

Commit

Permalink
fix: use mode instead of redraw when cmdheight=0. (Fixes #327)
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Sep 4, 2022
1 parent 7ee35a7 commit c966279
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lua/which-key/view.lua
Expand Up @@ -25,7 +25,7 @@ function M.is_valid()
end

function M.show()
M.is_visual_multi_mod = vim.b.visual_multi
M.is_visual_multi_mod = vim.b.visual_multi
if M.is_valid() then
return
end
Expand Down Expand Up @@ -122,7 +122,7 @@ function M.on_close()
end

function M.hide()
vim.cmd [[echon ""]]
vim.api.nvim_echo({ { "" } }, false, {})
M.hide_cursor()
if M.buf and vim.api.nvim_buf_is_valid(M.buf) then
vim.api.nvim_buf_delete(M.buf, { force = true })
Expand All @@ -132,10 +132,11 @@ function M.hide()
vim.api.nvim_win_close(M.win, { force = true })
M.win = nil
end
if M.is_visual_multi_mod then
M.is_visual_multi_mod = false
vim.cmd[[normal \\gS]] -- reselect visual-multi text
end
if M.is_visual_multi_mod then
M.is_visual_multi_mod = false
vim.cmd([[normal \\gS]]) -- reselect visual-multi text
end
vim.cmd("mode")
end

function M.show_cursor()
Expand Down Expand Up @@ -270,7 +271,11 @@ function M.on_keys(opts)

M.render(layout:layout(M.win))

vim.cmd([[redraw]])
if vim.opt.cmdheight:get() == 0 then
vim.cmd([[mode]])
else
vim.cmd([[redraw]])
end

local c = M.getchar()

Expand Down

0 comments on commit c966279

Please sign in to comment.