diff --git a/frontend/readhistory.lua b/frontend/readhistory.lua index 98de8d91e..bf3c8ab80 100644 --- a/frontend/readhistory.lua +++ b/frontend/readhistory.lua @@ -198,11 +198,12 @@ function ReadHistory:getPreviousFile(current_file) end end -function ReadHistory:getFileByDirectory(directory) +function ReadHistory:getFileByDirectory(directory, recursive) assert(self ~= nil) local real_path = realpath(directory) for i=1, #self.hist do - if realpath(ffiutil.dirname(self.hist[i].file)) == real_path then + local ipath = realpath(ffiutil.dirname(self.hist[i].file)) + if ipath == real_path or (recursive and util.stringStartsWith(ipath, real_path)) then return self.hist[i].file end end diff --git a/plugins/bookshortcuts.koplugin/main.lua b/plugins/bookshortcuts.koplugin/main.lua index 4b551d363..5466b9a1a 100644 --- a/plugins/bookshortcuts.koplugin/main.lua +++ b/plugins/bookshortcuts.koplugin/main.lua @@ -48,7 +48,7 @@ function BookShortcuts:onBookShortcut(path) end end else - file = ReadHistory:getFileByDirectory(path) + file = ReadHistory:getFileByDirectory(path, G_reader_settings:isTrue("BookShortcuts_recursive_directory")) end else file = path @@ -121,6 +121,13 @@ function BookShortcuts:getSubMenuItems() callback = function() G_reader_settings:saveSetting("BookShortcuts_directory_action", "FM") end, }, }, + }, + { + text = _("Recursively search folders"), + keep_menu_open = true, + checked_func = function() return G_reader_settings:isTrue("BookShortcuts_recursive_directory") end, + enabled_func = function() return G_reader_settings:readSetting("BookShortcuts_directory_action") == "Last" end, + callback = function() G_reader_settings:flipNilOrFalse("BookShortcuts_recursive_directory") end, separator = true, } }