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
|
-- Copyright (c) 2020-2021 shadmansaleh
|
||||||
-- MIT license, see LICENSE for more details.
|
-- MIT license, see LICENSE for more details.
|
||||||
local Branch = require('lualine.component'):new()
|
local Branch = require('lualine.component'):new()
|
||||||
|
local modules = require('lualine_require').lazy_require {
|
||||||
|
utils = 'lualine.utils.utils',
|
||||||
|
}
|
||||||
-- vars
|
-- vars
|
||||||
Branch.git_branch = ''
|
Branch.git_branch = ''
|
||||||
Branch.git_dir = ''
|
Branch.git_dir = ''
|
||||||
|
@ -20,12 +23,16 @@ Branch.new = function(self, options, child)
|
||||||
end
|
end
|
||||||
-- run watch head on load so branch is present when component is loaded
|
-- run watch head on load so branch is present when component is loaded
|
||||||
Branch.find_git_dir()
|
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
|
return new_branch
|
||||||
end
|
end
|
||||||
|
|
||||||
Branch.update_status = function(_, is_focused)
|
Branch.update_status = function(_, is_focused)
|
||||||
if Branch.active_bufnr ~= vim.g.actual_curbuf then
|
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()
|
Branch.find_git_dir()
|
||||||
end
|
end
|
||||||
if not is_focused then
|
if not is_focused then
|
||||||
|
|
|
@ -63,6 +63,7 @@ Diff.new = function(self, options, child)
|
||||||
|
|
||||||
if Diff.diff_checker_enabled then
|
if Diff.diff_checker_enabled then
|
||||||
-- setup internal source
|
-- 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()")
|
modules.utils.define_autocmd('BufWritePost', "lua require'lualine.components.diff'.update_git_diff()")
|
||||||
Diff.update_diff_args()
|
Diff.update_diff_args()
|
||||||
end
|
end
|
||||||
|
@ -75,7 +76,9 @@ Diff.update_status = function(self, is_focused)
|
||||||
local git_diff
|
local git_diff
|
||||||
if Diff.diff_checker_enabled then
|
if Diff.diff_checker_enabled then
|
||||||
if Diff.active_bufnr ~= vim.g.actual_curbuf 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()
|
Diff.update_diff_args()
|
||||||
end
|
end
|
||||||
git_diff = Diff.git_diff
|
git_diff = Diff.git_diff
|
||||||
|
|
Loading…
Reference in New Issue