Skip to content

Commit

Permalink
fix winid is not valid on floating terminal window
Browse files Browse the repository at this point in the history
  • Loading branch information
zztrieuzz committed Sep 4, 2022
1 parent 0872eb0 commit da7fd52
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lua/windline/components/git.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ M.git_branch = function(opt)
or utils.buf_get_var(bufnr, 'gitsigns_status_dict')
if git_dict and git_dict.head then
state.git_branch = git_dict.head
local icon = opt.icon or ' '
local icon = opt.icon or ' '
return icon .. git_dict.head
end
return ''
Expand Down
16 changes: 8 additions & 8 deletions lua/windline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ local render = function(bufnr, winid, items, cache)
M.state.mode = mode()
Comp.reset()
local status = ''
winid = winid or 0
local win_width = api.nvim_win_is_valid(winid) and M.get_status_width(winid)
winid = winid and api.nvim_win_is_valid(winid) and winid
or api.nvim_get_current_win()
local win_width = M.get_status_width(winid) or 0
for _, comp in pairs(items) do
if win_width and (comp.width == nil or comp.width < win_width) then
if comp.width == nil or comp.width < win_width then
status = status .. comp:render(bufnr, winid, win_width)
end
end
Expand Down Expand Up @@ -59,8 +60,7 @@ M.show_normal = function(bufnr, winid)

if vim.g.statusline_winid ~= cur_win then
-- in active
if
M.last_win == vim.g.statusline_winid
if M.last_win == vim.g.statusline_winid
and api.nvim_win_get_config(cur_win).relative ~= ''
then
M.state.last_status_win = nil
Expand Down Expand Up @@ -109,13 +109,13 @@ M.show = M.show_normal

M.show_global = function(bufnr, winid)
bufnr = bufnr or api.nvim_get_current_buf()
winid = winid or api.nvim_get_current_win()
winid = winid and api.nvim_win_is_valid(winid) and winid
or api.nvim_get_current_win()
local ft = api.nvim_buf_get_option(bufnr, 'filetype')
local check_line = M.get_statusline_ft(ft) or {}

if vim.g.statusline_winid == winid then
if
utils.is_in_table(M.state.config.global_skip_filetypes, ft)
if utils.is_in_table(M.state.config.global_skip_filetypes, ft)
or (
api.nvim_win_get_config(winid).relative ~= ''
and not check_line.global_show_float
Expand Down

0 comments on commit da7fd52

Please sign in to comment.