@@ -186,11 +186,11 @@ function create_select_tracklist_type_menu_opener(menu_title, track_type, track_
186186 })
187187end
188188
189- --- @alias NavigationMenuOptions { type : string , title ?: string , allowed_types ?: string[] , active_path ?: string , selected_path ?: string ; on_open ?: fun () ; on_close ?: fun ()}
189+ --- @alias NavigationMenuOptions { type : string , title ?: string , allowed_types ?: string[] , keep_open ?: boolean , active_path ?: string , selected_path ?: string ; on_open ?: fun () ; on_close ?: fun ()}
190190
191191-- Opens a file navigation menu with items inside `directory_path`.
192192--- @param directory_path string
193- --- @param handle_select fun ( path : string ): nil
193+ --- @param handle_select fun ( path : string , mods : Modifiers ): nil
194194--- @param opts NavigationMenuOptions
195195function open_file_navigation_menu (directory_path , handle_select , opts )
196196 directory = serialize_path (normalize_path (directory_path ))
@@ -251,6 +251,7 @@ function open_file_navigation_menu(directory_path, handle_select, opts)
251251 local is_to_parent = is_drives or # path < # directory_path
252252 local inheritable_options = {
253253 type = opts .type , title = opts .title , allowed_types = opts .allowed_types , active_path = opts .active_path ,
254+ keep_open = opts .keep_open ,
254255 }
255256
256257 if is_drives then
@@ -273,15 +274,15 @@ function open_file_navigation_menu(directory_path, handle_select, opts)
273274 return
274275 end
275276
276- if info .is_dir and not meta .modifiers .alt then
277+ if info .is_dir and not meta .modifiers .alt and not meta . modifiers . ctrl then
277278 -- Preselect directory we are coming from
278279 if is_to_parent then
279280 inheritable_options .selected_path = directory .path
280281 end
281282
282283 open_file_navigation_menu (path , handle_select , inheritable_options )
283284 else
284- handle_select (path )
285+ handle_select (path , meta . modifiers )
285286 end
286287 end
287288
@@ -293,6 +294,7 @@ function open_file_navigation_menu(directory_path, handle_select, opts)
293294 type = opts .type ,
294295 title = opts .title or directory .basename .. path_separator ,
295296 items = items ,
297+ keep_open = opts .keep_open ,
296298 selected_index = selected_index ,
297299 }
298300 local menu_options = {on_open = opts .on_open , on_close = opts .on_close , on_back = handle_back }
@@ -535,11 +537,19 @@ function open_open_file_menu()
535537
536538 menu = open_file_navigation_menu (
537539 directory ,
538- function (path ) mp .commandv (' loadfile' , path ) end ,
540+ function (path , mods )
541+ if mods .ctrl then
542+ mp .commandv (' loadfile' , path , ' append' )
543+ else
544+ mp .commandv (' loadfile' , path )
545+ Menu :close ()
546+ end
547+ end ,
539548 {
540549 type = ' open-file' ,
541550 allowed_types = config .types .media ,
542551 active_path = active_file ,
552+ keep_open = true ,
543553 on_open = function () mp .register_event (' file-loaded' , handle_file_loaded ) end ,
544554 on_close = function () mp .unregister_event (handle_file_loaded ) end ,
545555 }
0 commit comments