Skip to content

Commit

Permalink
fix(on_click): pass winid to on_click callback
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelot committed May 29, 2022
1 parent bb7eaec commit c13b7d8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lua/heirline/statusline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ function StatusLine:get_win_attr(attr, default)
return self[attr][winnr]
end

local function register_global_function(component, on_click)
local function register_global_function(component)
local on_click = component.on_click
local winid = vim.api.nvim_get_current_win()

if type(on_click.callback) == "string" then
return on_click.callback
end
Expand All @@ -124,7 +127,7 @@ local function register_global_function(component, on_click)
end

_G[func_name] = function(minwid, nclicks, button)
on_click.callback(component, minwid, nclicks, button)
on_click.callback(component, winid, minwid, nclicks, button)
end
return "v:lua." .. func_name
end
Expand All @@ -150,7 +153,7 @@ function StatusLine:eval()
end

if self.on_click then
local func_name = register_global_function(self, self.on_click)
local func_name = register_global_function(self)
table.insert(stl, "%@" .. func_name .. "@")
end

Expand Down

0 comments on commit c13b7d8

Please sign in to comment.