fix: search_submenus
inheritance, missing docs, and ass_safe_title
cache not clearing
ref #677
This commit is contained in:
@@ -431,6 +431,7 @@ Menu {
|
|||||||
palette?: boolean;
|
palette?: boolean;
|
||||||
search_debounce?: 'submit' | number;
|
search_debounce?: 'submit' | number;
|
||||||
search_suggestion?: string;
|
search_suggestion?: string;
|
||||||
|
search_submenus?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item = Command | Submenu;
|
Item = Command | Submenu;
|
||||||
@@ -444,6 +445,7 @@ Submenu {
|
|||||||
palette?: boolean;
|
palette?: boolean;
|
||||||
search_debounce?: 'submit' | number;
|
search_debounce?: 'submit' | number;
|
||||||
search_suggestion?: string;
|
search_suggestion?: string;
|
||||||
|
search_submenus?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
Command {
|
Command {
|
||||||
@@ -470,7 +472,7 @@ While the menu is open this value will be available in `user-data/uosc/menu/type
|
|||||||
|
|
||||||
`search_debounce` controls how soon the search happens after the last character was entered in milliseconds. Entering new character resets the timer. Defaults to `300`. It can also have a special value `'submit'`, which triggers a search only after `ctrl+enter` was pressed.
|
`search_debounce` controls how soon the search happens after the last character was entered in milliseconds. Entering new character resets the timer. Defaults to `300`. It can also have a special value `'submit'`, which triggers a search only after `ctrl+enter` was pressed.
|
||||||
|
|
||||||
`search_submenus` makes uosc's internal search handler (when no `on_search` callback is defined) look into submenus as well, effectively flattening the menu for the duration of the search.
|
`search_submenus` makes uosc's internal search handler (when no `on_search` callback is defined) look into submenus as well, effectively flattening the menu for the duration of the search. This property is inherited by all submenus.
|
||||||
|
|
||||||
`search_suggestion` fills menu search with initial query string. Useful for example when you want to implement something like subtitle downloader, you'd set it to current file name.
|
`search_suggestion` fills menu search with initial query string. Useful for example when you want to implement something like subtitle downloader, you'd set it to current file name.
|
||||||
|
|
||||||
|
@@ -689,7 +689,12 @@ function Menu:search_internal(menu)
|
|||||||
-- Reset menu state to what it was before search
|
-- Reset menu state to what it was before search
|
||||||
for key, value in pairs(menu.search.source) do menu[key] = value end
|
for key, value in pairs(menu.search.source) do menu[key] = value end
|
||||||
else
|
else
|
||||||
menu.items = search_items(menu.search.source.items, query, menu.search_submenus)
|
-- Inherit `search_submenus` from parent menus
|
||||||
|
local search_submenus, parent_menu = menu.search_submenus, menu.parent_menu
|
||||||
|
while not search_submenus and parent_menu do
|
||||||
|
search_submenus, parent_menu = parent_menu.search_submenus, parent_menu.parent_menu
|
||||||
|
end
|
||||||
|
menu.items = search_items(menu.search.source.items, query, search_submenus)
|
||||||
-- Select 1st item in search results
|
-- Select 1st item in search results
|
||||||
menu.scroll_y = 0
|
menu.scroll_y = 0
|
||||||
self:select_index(1, menu)
|
self:select_index(1, menu)
|
||||||
@@ -717,6 +722,7 @@ function search_items(items, query, recursive, prefix)
|
|||||||
hint and table.concat(initials(hint)):find(query, 1, true) then
|
hint and table.concat(initials(hint)):find(query, 1, true) then
|
||||||
item = table_shallow_copy(item)
|
item = table_shallow_copy(item)
|
||||||
item.title = prefixed_title
|
item.title = prefixed_title
|
||||||
|
item.ass_safe_title = nil
|
||||||
result[#result + 1] = item
|
result[#result + 1] = item
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user