From 3463bd09f54a5c28eeedee2a70fa07c1e0bcfe4c Mon Sep 17 00:00:00 2001 From: darrenchang951 Date: Fri, 18 Oct 2024 11:50:49 -0400 Subject: [PATCH 1/2] Fix git_diff custom source bug with auto-session - git_diff does not cache git_sign_count into diff_cache when rmagatti/auto-session plugin is used to launch nvim session with multiple open windows. - This commit makes sure to not use diff_cache value, but instead, uses the custom source to get git sign counts when M.src (custome source for git_diff) is defined. --- lua/lualine/components/diff/git_diff.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lualine/components/diff/git_diff.lua b/lua/lualine/components/diff/git_diff.lua index a460f8f16..7c04a50e8 100644 --- a/lua/lualine/components/diff/git_diff.lua +++ b/lua/lualine/components/diff/git_diff.lua @@ -39,7 +39,7 @@ end ---error_code = { added = -1, modified = -1, removed = -1 } ---@param bufnr number|nil function M.get_sign_count(bufnr) - if bufnr then + if bufnr and not (type(M.src) == 'function') then return diff_cache[bufnr] end if M.src then From d5793758e760c64dfffd6b12f2250f13dca1ce0d Mon Sep 17 00:00:00 2001 From: darrenchang951 Date: Sun, 20 Oct 2024 21:08:59 -0400 Subject: [PATCH 2/2] Fix linter issue --- lua/lualine/components/diff/git_diff.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lualine/components/diff/git_diff.lua b/lua/lualine/components/diff/git_diff.lua index 7c04a50e8..562abe0fa 100644 --- a/lua/lualine/components/diff/git_diff.lua +++ b/lua/lualine/components/diff/git_diff.lua @@ -39,7 +39,7 @@ end ---error_code = { added = -1, modified = -1, removed = -1 } ---@param bufnr number|nil function M.get_sign_count(bufnr) - if bufnr and not (type(M.src) == 'function') then + if bufnr and (type(M.src) ~= 'function') then return diff_cache[bufnr] end if M.src then