BugFix: Fix function component not working (#175)

When the provided function takes an optional argument the previous
implementation causes error.
This commit is contained in:
Shadman 2021-04-13 23:09:01 +06:00 committed by GitHub
parent 4f53d053a1
commit aa844a9555
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -1,9 +1,8 @@
local FunctionComponent = require('lualine.component'):new()
FunctionComponent.new = function(self, options, child)
local new_instence = self._parent:new(options, child or FunctionComponent)
new_instence.update_status = options[1]
return new_instence
FunctionComponent.update_status = function(self)
-- 1st element in options table is the function provided by config
return self.options[1]()
end
return FunctionComponent