fix: Possible fix to diff sometimws not apearing
This commit is contained in:
parent
62b53c854c
commit
ac9a9e0a8b
|
@ -62,13 +62,8 @@ Diff.new = function(self, options, child)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- call update functions so git diff is present when component is loaded
|
|
||||||
Diff.update_git_diff_getter()
|
|
||||||
Diff.update_git_diff()
|
|
||||||
|
|
||||||
vim.api.nvim_exec([[
|
vim.api.nvim_exec([[
|
||||||
autocmd lualine BufEnter * lua require'lualine.components.diff'.update_git_diff_getter()
|
autocmd lualine BufEnter * lua require'lualine.components.diff'.update_git_diff_getter()
|
||||||
autocmd lualine BufEnter * lua require'lualine.components.diff'.update_git_diff()
|
|
||||||
autocmd lualine BufWritePost * lua require'lualine.components.diff'.update_git_diff()
|
autocmd lualine BufWritePost * lua require'lualine.components.diff'.update_git_diff()
|
||||||
]], false)
|
]], false)
|
||||||
|
|
||||||
|
@ -153,7 +148,6 @@ function Diff.update_git_diff_getter()
|
||||||
-- stop older function properly before overwritting it
|
-- stop older function properly before overwritting it
|
||||||
if Diff.get_git_diff then
|
if Diff.get_git_diff then
|
||||||
Diff.get_git_diff:stop()
|
Diff.get_git_diff:stop()
|
||||||
Diff.diff_data = ''
|
|
||||||
end
|
end
|
||||||
-- Donn't show git diff when current buffer doesn't have a filename
|
-- Donn't show git diff when current buffer doesn't have a filename
|
||||||
if #vim.fn.expand('%') == 0 then
|
if #vim.fn.expand('%') == 0 then
|
||||||
|
@ -177,22 +171,20 @@ function Diff.update_git_diff_getter()
|
||||||
on_exit = function()
|
on_exit = function()
|
||||||
if Diff.diff_data ~= '' then
|
if Diff.diff_data ~= '' then
|
||||||
Diff.process_diff(Diff.diff_data)
|
Diff.process_diff(Diff.diff_data)
|
||||||
Diff.diff_data = ''
|
|
||||||
else
|
else
|
||||||
Diff.git_diff = {added = 0, modified = 0, removed = 0}
|
Diff.git_diff = {added = 0, modified = 0, removed = 0}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
Diff.update_git_diff()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update git_diff veriable
|
-- Update git_diff veriable
|
||||||
function Diff.update_git_diff()
|
function Diff.update_git_diff()
|
||||||
vim.schedule_wrap(function()
|
if Diff.get_git_diff then
|
||||||
if Diff.get_git_diff then
|
Diff.diff_data = ''
|
||||||
Diff.diff_data = ''
|
Diff.get_git_diff:start()
|
||||||
Diff.get_git_diff:start()
|
end
|
||||||
end
|
|
||||||
end)()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return Diff
|
return Diff
|
||||||
|
|
Loading…
Reference in New Issue