Skip to content

Commit 0d0079c

Browse files
fix(popup): create popup after set nomodifiable, closes #570 (#571)
* fix(popup): nomodifiable popup, closes #570 * feat: added test for `set nomodifiable`
1 parent 8aad439 commit 0d0079c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lua/plenary/popup/init.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ function popup.create(what, vim_options)
123123
assert(bufnr, "Failed to create buffer")
124124

125125
vim.api.nvim_buf_set_option(bufnr, "bufhidden", "wipe")
126+
if vim.o.modifiable == false then
127+
vim.api.nvim_buf_set_option(bufnr, "modifiable", true)
128+
end
126129

127130
-- TODO: Handle list of lines
128131
if type(what) == "string" then

tests/plenary/popup_spec.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ describe("plenary.popup", function()
2222
eq(20, win_config.width)
2323
end)
2424

25+
it("can create a very simple window after 'set nomodifiable'", function()
26+
vim.o.modifiable = false
27+
local win_id = popup.create("hello there", {
28+
line = 1,
29+
col = 1,
30+
width = 20,
31+
})
32+
33+
local win_config = vim.api.nvim_win_get_config(win_id)
34+
eq(20, win_config.width)
35+
vim.o.modifiable = true
36+
end)
37+
2538
it("can apply a highlight", function()
2639
local win_id = popup.create("hello there", {
2740
highlight = "PopupColor1",

0 commit comments

Comments
 (0)