Skip to content

Commit

Permalink
fix(view): set modifiable flag for view buffer (#506)
Browse files Browse the repository at this point in the history
This change provides a fix to somewhat niche use case when user has
`nomodifiable` option enabled globally. Currently, if `nomodifiable`
option is enabled globally it causes plugin to reach unrecoverable state
when 'view' window shows nothing and each key press produces only more
Lua exceptions.

Enabling `modifiable` flag on buffer creation ensures the proper state
of new scratch buffer, no matter what the current global value is.

Co-authored-by: mivort <5783792+mivort@users.noreply.github.com>
  • Loading branch information
mivort and mivort committed Oct 17, 2023
1 parent 6962dae commit 1d17760
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lua/which-key/view.lua
Expand Up @@ -79,6 +79,7 @@ function M.show()
vim.api.nvim_buf_set_option(M.buf, "filetype", "WhichKey")
vim.api.nvim_buf_set_option(M.buf, "buftype", "nofile")
vim.api.nvim_buf_set_option(M.buf, "bufhidden", "wipe")
vim.api.nvim_buf_set_option(M.buf, "modifiable", true)

local winhl = "NormalFloat:WhichKeyFloat"
if vim.fn.hlexists("FloatBorder") == 1 then
Expand Down

0 comments on commit 1d17760

Please sign in to comment.