Skip to content

Commit 2a16692

Browse files
committed
bug: Clearing popup message box causes exception
1 parent 3ab6c51 commit 2a16692

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lua/stopinsert/popup.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
local M = {}
2-
local config = require("stopinsert.config")
32

43
--- Create a simple popup message, positioned in the bottom right corner of the buffer
5-
--- Automatically close this popup after 5 seconds
4+
--- Automatically close this popup after timeout_ms milliseconds
65
--- Courtersy of encourage.nvim
76
---@param message string
7+
---@param timeout_ms number
88
---@return nil
9-
function M.show(message)
9+
function M.show(message, timeout_ms)
1010
local width = #message
1111
local height = 1
1212
local buf = vim.api.nvim_create_buf(false, true)
@@ -34,7 +34,7 @@ function M.show(message)
3434
if vim.api.nvim_win_is_valid(win) then
3535
vim.api.nvim_win_close(win, true)
3636
end
37-
end, config.clear_popup_ms)
37+
end, timeout_ms)
3838
end
3939

4040
return M

lua/stopinsert/util.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ function M.force_exit_insert_mode()
99
vim.cmd("stopinsert")
1010

1111
if config.show_popup_msg then
12-
popup.show("StopInsertPlug: You were idling in Insert mode. Remeber to <Esc> when you finish editing.")
12+
local msg = "StopInsertPlug: You were idling in Insert mode. Remeber to <Esc> when you finish editing."
13+
popup.show(msg, config.clear_popup_ms)
1314
end
1415
end
1516
end

0 commit comments

Comments
 (0)