1- --- @class State
2- --- @field cfg Config
3- --- @field api_cache table<string,ApiCrate>
4- --- @field buf_cache table<integer,BufCache>
5- --- @field search_cache SearchCache
6- --- @field visible boolean
7- local State = {
8- buf_cache = {},
9- search_cache = {
10- results = {},
11- searches = {},
12- },
13- visible = true ,
14- }
15-
161--- @param name string
172--- @return string
183local function normalize_crate_name (name )
@@ -41,8 +26,6 @@ function ApiCache:__newindex(key, value)
4126 return rawset (self , id , value )
4227end
4328
44- State .api_cache = ApiCache .new ()
45-
4629--- @class BufCache
4730--- @field crates table<string,TomlCrate>
4831--- @field info table<string,CrateInfo>
@@ -53,4 +36,28 @@ State.api_cache = ApiCache.new()
5336--- @field searches table<string , string[]>
5437--- @field results table<string , ApiCrateSummary>
5538
39+ --- @class State
40+ --- @field cfg Config
41+ --- @field buf_cache table<integer,BufCache>
42+ --- @field api_cache table<string,ApiCrate>
43+ --- @field search_cache SearchCache
44+ --- @field visible boolean
45+ local State = {
46+ buf_cache = {},
47+ api_cache = ApiCache .new (),
48+ search_cache = {
49+ results = {},
50+ searches = {},
51+ },
52+ visible = true ,
53+ }
54+
55+ function State :clear_cache ()
56+ self .api_cache = ApiCache .new ()
57+ self .search_cache = {
58+ results = {},
59+ searches = {},
60+ }
61+ end
62+
5663return State
0 commit comments