refactor(file-search): use closure callbacks
This commit is contained in:
+2
-12
@@ -26,16 +26,6 @@ local render
|
|||||||
local runSearch
|
local runSearch
|
||||||
local buildIndex
|
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)
|
local function tr(key, args)
|
||||||
return noctalia.tr(key, args)
|
return noctalia.tr(key, args)
|
||||||
end
|
end
|
||||||
@@ -258,9 +248,9 @@ local function resultRow(rel, index)
|
|||||||
text = rel,
|
text = rel,
|
||||||
variant = "ghost",
|
variant = "ghost",
|
||||||
contentAlign = "start",
|
contentAlign = "start",
|
||||||
onClick = rowCallback("openHit", index, function()
|
onClick = function()
|
||||||
openEntry(rel)
|
openEntry(rel)
|
||||||
end),
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
id = "nightwatch75/file-search"
|
id = "nightwatch75/file-search"
|
||||||
name = "File Search"
|
name = "File Search"
|
||||||
version = "0.0.10"
|
version = "0.0.11"
|
||||||
plugin_api = 3
|
plugin_api = 9
|
||||||
author = "nightwatch75"
|
author = "nightwatch75"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
# The exact commands the plugin spawns (fzf aside, findutils + coreutils +
|
# The exact commands the plugin spawns (fzf aside, findutils + coreutils +
|
||||||
|
|||||||
Reference in New Issue
Block a user