refactor(file-search): use closure callbacks
This commit is contained in:
+2
-12
@@ -26,16 +26,6 @@ local render
|
||||
local runSearch
|
||||
local buildIndex
|
||||
|
||||
-- Per-row callbacks need distinct global names; the reconciler dispatches
|
||||
-- callbacks by name only. getfenv() is the script environment lua_getglobal
|
||||
-- reads from, so assigning into it defines the callback the host will find.
|
||||
local env = getfenv()
|
||||
local function rowCallback(prefix, index, fn)
|
||||
local name = prefix .. "_" .. index
|
||||
env[name] = fn
|
||||
return name
|
||||
end
|
||||
|
||||
local function tr(key, args)
|
||||
return noctalia.tr(key, args)
|
||||
end
|
||||
@@ -258,9 +248,9 @@ local function resultRow(rel, index)
|
||||
text = rel,
|
||||
variant = "ghost",
|
||||
contentAlign = "start",
|
||||
onClick = rowCallback("openHit", index, function()
|
||||
onClick = function()
|
||||
openEntry(rel)
|
||||
end),
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
id = "nightwatch75/file-search"
|
||||
name = "File Search"
|
||||
version = "0.0.10"
|
||||
plugin_api = 3
|
||||
version = "0.0.11"
|
||||
plugin_api = 9
|
||||
author = "nightwatch75"
|
||||
license = "MIT"
|
||||
# The exact commands the plugin spawns (fzf aside, findutils + coreutils +
|
||||
|
||||
Reference in New Issue
Block a user