Skip to content

Commit 399f92d

Browse files
committed
chore: replace U.get_pattern() with U.is_fn()
1 parent 026ec95 commit 399f92d

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

lua/Comment/opfunc.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ end
100100
---@return integer CMode
101101
function O.linewise(p)
102102
local lcs_esc, rcs_esc = U.escape(p.lcs), U.escape(p.rcs)
103-
local pattern = U.get_pattern(p.cfg.ignore)
103+
local pattern = U.is_fn(p.cfg.ignore)
104104
local padding, pp = U.get_padding(p.cfg.padding)
105105
local is_commented = U.is_commented(lcs_esc, rcs_esc, pp)
106106

lua/Comment/utils.lua

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,13 @@ function U.escape(str)
9393
end
9494

9595
---Call a function if exists
96-
---@param fn function Hook function
96+
---@param fn function Wanna be function
9797
---@return boolean|string
9898
function U.is_fn(fn, ...)
99-
return type(fn) == 'function' and fn(...)
100-
end
101-
102-
---Helper to compute the ignore pattern
103-
---@param ig string|function
104-
---@return boolean|string
105-
function U.get_pattern(ig)
106-
return ig and (type(ig) == 'string' and ig or U.is_fn(ig))
99+
if type(fn) == 'function' then
100+
return fn(...)
101+
end
102+
return fn
107103
end
108104

109105
---Check if the given line is ignored or not with the given pattern

0 commit comments

Comments
 (0)