From aeeefcef98ce48315deaa274a19a9847a1753b8e Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Thu, 28 Jul 2022 13:03:10 +0600 Subject: [PATCH] fix: don't show notification for empty LualineNotice Previously even if config error was resolved in following setup call notification for LualineNotice was displayed and when user opened LualineNotice it'll be empty leaving users confused. Now we'll wait for 2s before sending notification for LualineNotice so if successive calls to setup fixed the config error the notification will not be shown. --- lua/lualine/utils/notices.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lua/lualine/utils/notices.lua b/lua/lualine/utils/notices.lua index 708016f..4d8001f 100644 --- a/lua/lualine/utils/notices.lua +++ b/lua/lualine/utils/notices.lua @@ -28,17 +28,23 @@ end ---show setup :LuaLineNotices and show notification about error when there ---are notices available +local notify_done = false function M.notice_message_startup() - if #notices > 0 or #persistent_notices > 0 then - vim.cmd('command! -nargs=0 LualineNotices lua require"lualine.utils.notices".show_notices()') - vim.schedule(function() + notify_done = false + vim.defer_fn(function() + if notify_done then + return + end + if #notices > 0 or #persistent_notices > 0 then + vim.cmd('command! -nargs=0 LualineNotices lua require"lualine.utils.notices".show_notices()') vim.notify( 'lualine: There are some issues with your config. Run :LualineNotices for details', vim.log.levels.WARN, {} ) - end) - end + end + notify_done = true + end, 2000) end ---create notice view