From 7ed5b6ee15ff85d18409a426643fcb386303b0a7 Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Thu, 17 Apr 2025 13:06:03 +0200 Subject: [PATCH] chore: final clean up of `Class._wrapFunction` --- lua/wikis/commons/Class.lua | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/lua/wikis/commons/Class.lua b/lua/wikis/commons/Class.lua index 7df41af0415..e23efbc3a61 100644 --- a/lua/wikis/commons/Class.lua +++ b/lua/wikis/commons/Class.lua @@ -85,30 +85,9 @@ end ---@param options table? ---@return F function Class._wrapFunction(f, options) - options = options or {} - local alwaysRewriteArgs = options.trim - or options.removeBlanks - or options.valueFunc ~= nil - - return function(...) - -- We cannot call getArgs with a spread operator when these are just lua - -- args, so we need to wrap it - local input = {...} - - local frame = input[1] - local shouldRewriteArgs = alwaysRewriteArgs - or ( - #input == 1 - and type(frame) == 'table' - and type(frame.args) == 'table' - ) - - if shouldRewriteArgs then - local args = Arguments.getArgs(frame, options) - return f(args) - else - return f(...) - end + return function(frameOrArgs) + local args = Arguments.getArgs(frameOrArgs, options or {}) + return f(args) end end