Skip to content

Commit

Permalink
bug: Clearing popup message box causes exception
Browse files Browse the repository at this point in the history
  • Loading branch information
csessh committed Oct 8, 2024
1 parent 3ab6c51 commit 2a16692
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lua/stopinsert/popup.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
local M = {}
local config = require("stopinsert.config")

--- Create a simple popup message, positioned in the bottom right corner of the buffer
--- Automatically close this popup after 5 seconds
--- Automatically close this popup after timeout_ms milliseconds
--- Courtersy of encourage.nvim
---@param message string
---@param timeout_ms number
---@return nil
function M.show(message)
function M.show(message, timeout_ms)
local width = #message
local height = 1
local buf = vim.api.nvim_create_buf(false, true)
Expand Down Expand Up @@ -34,7 +34,7 @@ function M.show(message)
if vim.api.nvim_win_is_valid(win) then
vim.api.nvim_win_close(win, true)
end
end, config.clear_popup_ms)
end, timeout_ms)
end

return M
3 changes: 2 additions & 1 deletion lua/stopinsert/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ function M.force_exit_insert_mode()
vim.cmd("stopinsert")

if config.show_popup_msg then
popup.show("StopInsertPlug: You were idling in Insert mode. Remeber to <Esc> when you finish editing.")
local msg = "StopInsertPlug: You were idling in Insert mode. Remeber to <Esc> when you finish editing."
popup.show(msg, config.clear_popup_ms)
end
end
end
Expand Down

0 comments on commit 2a16692

Please sign in to comment.