Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(view): set modifiable flag for view buffer #506

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

mivort
Copy link
Contributor

@mivort mivort commented Sep 1, 2023

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.

Without this change, running :set nomodifiable and then pressing any key produces the following exception:

E5108: Error executing lua .../which-key.nvim/lua/which-key/view.lua:336: Buffer is not 'modifiable'
stack traceback:
        [C]: in function 'nvim_buf_set_lines'
        .../which-key.nvim/lua/which-key/view.lua:336: in function 'render'
        .../which-key.nvim/lua/which-key/view.lua:313: in function 'on_keys'
        .../which-key.nvim/lua/which-key/view.lua:255: in function 'open'
        .../which-key.nvim/lua/which-key/init.lua:49: in function 'show'
        [string ":lua"]:1: in main chunk

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.
@folke folke linked an issue Oct 17, 2023 that may be closed by this pull request
3 tasks
@folke folke merged commit 1d17760 into folke:main Oct 17, 2023
willothy pushed a commit to willothy/which-key.nvim that referenced this pull request Jan 27, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Unexpected behavior on buffer with "modifiable" set to "off"
2 participants