-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: attach plugin
args
to the entry
method for better future opt…
…imization possibilities (#627)
- Loading branch information
Showing
3 changed files
with
23 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
local cache = {} | ||
local sub_mt = { | ||
__index = function(target, k) | ||
local bucket = rawget(target, "__yazi_bucket") | ||
return cache[bucket] and cache[bucket][k] | ||
end, | ||
__newindex = function(target, k, v) | ||
local bucket = rawget(target, "__yazi_bucket") | ||
cache[bucket] = cache[bucket] or {} | ||
cache[bucket][k] = v | ||
end, | ||
} | ||
|
||
state = setmetatable({ | ||
clear = function() cache[YAZI_PLUGIN_NAME] = nil end, | ||
}, { | ||
state = setmetatable({}, { | ||
__index = function(_, k) | ||
local bucket = YAZI_PLUGIN_NAME | ||
return cache[bucket] and cache[bucket][k] | ||
end, | ||
|
||
__newindex = function(_, k, v) | ||
local bucket = YAZI_PLUGIN_NAME | ||
cache[bucket] = cache[bucket] or {} | ||
cache[bucket][k] = v | ||
end, | ||
__call = function() return setmetatable({ __yazi_bucket = YAZI_PLUGIN_NAME }, sub_mt) end, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters