Skip to content

Commit b3d1632

Browse files
allow browse_directory to be called without opening the browser
1 parent 4d7823d commit b3d1632

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

docs/addons.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,12 @@ The current API version in use by file-browser.
443443

444444
Adds the given extension to the default extension filter whitelist. Can only be run inside the `setup()` method.
445445

446-
#### `fb.browse_directory(directory: string): void`
446+
#### `fb.browse_directory(directory: string, open_browser: bool = true): void`
447447

448-
Clears the cache and opens the given directory in the browser. If the browser is closed then it will be opened.
448+
Clears the cache and opens the given directory in the browser.
449+
If the `open_browser` argument is truthy or `nil` then the browser will be opened
450+
if it is currently closed. If `open_browser` is `false` then the directory will
451+
be opened in the background.
449452
This function is non-blocking, it is possible that the function will return before the directory has finished
450453
being scanned.
451454

modules/controls.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ function controls.escape()
7171
end
7272

7373
--opens a specific directory
74-
function controls.browse_directory(directory)
74+
function controls.browse_directory(directory, open_browser)
7575
if not directory then return end
76+
if open_browser == nil then open_browser = true end
77+
7678
directory = mp.command_native({"expand-path", directory}) or ''
7779
-- directory = join_path( mp.get_property("working-directory", ""), directory )
7880

@@ -81,7 +83,7 @@ function controls.browse_directory(directory)
8183

8284
directory = fb_utils.resolve_directory_mapping(directory)
8385
movement.goto_directory(directory)
84-
controls.open()
86+
if open_browser then controls.open() end
8587
end
8688

8789
return controls

0 commit comments

Comments
 (0)