fix: file menu not updating active item and other menu issues

- Preselecting previous folder wasn't working sometimes.
- `join_path()` didn't account for drive letters already having a separator.

Also refactors how `open_file_navigation_menu()` stores menu items value. As a side effect this is now a lot faster as we don't have to serialize each item's path into meta table, but instead we now store just a path string and handle it as needed.

closes #355
This commit is contained in:
tomasklaen
2022-10-31 11:10:25 +01:00
parent e8060c74ad
commit 5f5bf4b842
4 changed files with 59 additions and 58 deletions

View File

@@ -351,7 +351,7 @@ end
---@param menu? MenuStack
function Menu:select_value(value, menu)
menu = menu or self.current
local index = itable_find(menu.items, function(_, item) return item.value == value end)
local index = itable_find(menu.items, function(item) return item.value == value end)
self:select_index(index, 5)
end
@@ -372,7 +372,7 @@ end
---@param index? integer
---@param menu? MenuStack
function Menu:activate_unique_index(index, menu)
function Menu:activate_one_index(index, menu)
self:deactivate_items(menu)
self:activate_index(index, menu)
end
@@ -381,16 +381,16 @@ end
---@param menu? MenuStack
function Menu:activate_value(value, menu)
menu = menu or self.current
local index = itable_find(menu.items, function(_, item) return item.value == value end)
local index = itable_find(menu.items, function(item) return item.value == value end)
self:activate_index(index, menu)
end
---@param value? any
---@param menu? MenuStack
function Menu:activate_unique_value(value, menu)
function Menu:activate_one_value(value, menu)
menu = menu or self.current
local index = itable_find(menu.items, function(_, item) return item.value == value end)
self:activate_unique_index(index, menu)
local index = itable_find(menu.items, function(item) return item.value == value end)
self:activate_one_index(index, menu)
end
---@param id string
@@ -420,7 +420,7 @@ end
---@param menu? MenuStack
function Menu:delete_value(value, menu)
menu = menu or self.current
local index = itable_find(menu.items, function(_, item) return item.value == value end)
local index = itable_find(menu.items, function(item) return item.value == value end)
self:delete_index(index)
end