Revert: enahce: sync diff&branch component to buffer based of bufnr instead of BufEnter
functionally reverted commit 2b90200998
nvim gives first scratch buffer(when opened without a file) and the
first opened buffer bufnr 1 . That's why we can't relay completely
on bufnr being different to indicate file is different. So back to
BufEnter autocommands.
closes #38
This commit is contained in:
parent
a26ffaa8ed
commit
0e0cf68eba
|
@ -1,6 +1,9 @@
|
|||
-- Copyright (c) 2020-2021 shadmansaleh
|
||||
-- MIT license, see LICENSE for more details.
|
||||
local Branch = require('lualine.component'):new()
|
||||
local modules = require('lualine_require').lazy_require {
|
||||
utils = 'lualine.utils.utils',
|
||||
}
|
||||
-- vars
|
||||
Branch.git_branch = ''
|
||||
Branch.git_dir = ''
|
||||
|
@ -20,12 +23,16 @@ Branch.new = function(self, options, child)
|
|||
end
|
||||
-- run watch head on load so branch is present when component is loaded
|
||||
Branch.find_git_dir()
|
||||
-- update branch state of BufEnter as different Buffer may be on different repos
|
||||
modules.utils.define_autocmd('BufEnter', "lua require'lualine.components.branch'.find_git_dir()")
|
||||
return new_branch
|
||||
end
|
||||
|
||||
Branch.update_status = function(_, is_focused)
|
||||
if Branch.active_bufnr ~= vim.g.actual_curbuf then
|
||||
-- Sync buffer
|
||||
-- Workaround for https://github.com/hoob3rt/lualine.nvim/issues/286
|
||||
-- See upstream issue https://github.com/neovim/neovim/issues/15300
|
||||
-- Diff is out of sync re sync it.
|
||||
Branch.find_git_dir()
|
||||
end
|
||||
if not is_focused then
|
||||
|
|
|
@ -63,6 +63,7 @@ Diff.new = function(self, options, child)
|
|||
|
||||
if Diff.diff_checker_enabled then
|
||||
-- setup internal source
|
||||
modules.utils.define_autocmd('BufEnter', "lua require'lualine.components.diff'.update_diff_args()")
|
||||
modules.utils.define_autocmd('BufWritePost', "lua require'lualine.components.diff'.update_git_diff()")
|
||||
Diff.update_diff_args()
|
||||
end
|
||||
|
@ -75,7 +76,9 @@ Diff.update_status = function(self, is_focused)
|
|||
local git_diff
|
||||
if Diff.diff_checker_enabled then
|
||||
if Diff.active_bufnr ~= vim.g.actual_curbuf then
|
||||
-- Sync buffer
|
||||
-- Workaround for https://github.com/hoob3rt/lualine.nvim/issues/286
|
||||
-- See upstream issue https://github.com/neovim/neovim/issues/15300
|
||||
-- Diff is out of sync re sync it.
|
||||
Diff.update_diff_args()
|
||||
end
|
||||
git_diff = Diff.git_diff
|
||||
|
|
Loading…
Reference in New Issue