Skip to content

Commit 9de1866

Browse files
when moving up a directory do not stop on empty protocol schemes
e.g. moving up from `ftp://localhost/` will move straight to the root instead of `ftp://` First brought up in (#104)
1 parent 05a3b91 commit 9de1866

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

docs/file_browser.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ autoload_save_current=yes
7777
# move the browser there even if this option is set to false
7878
default_to_working_directory=no
7979

80+
# when moving up a directory do not stop on empty protocol schemes like `ftp://`
81+
# e.g. moving up from `ftp://localhost/` will move straight to the root instead of `ftp://`
82+
skip_protocol_schemes=yes
83+
8084
# enables addons
8185
addons=no
8286
addon_directory=~~/script-modules/file-browser-addons

modules/navigation/directory-movement.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
local msg = require 'mp.msg'
33

4+
local o = require 'modules.options'
45
local g = require 'modules.globals'
56
local cache = require 'modules.cache'
67
local scanning = require 'modules.navigation.scanning'
@@ -29,6 +30,12 @@ end
2930
--moves up a directory
3031
function directory_movement.up_dir()
3132
local parent_dir = g.state.directory:match("^(.-/+)[^/]+/*$") or ""
33+
34+
if o.skip_protocol_schemes and parent_dir:find("^(%a[%w+-.]*)://$") then
35+
directory_movement.goto_root()
36+
return;
37+
end
38+
3239
g.state.directory = parent_dir
3340

3441
--we can make some assumptions about the next directory label when moving up or down

modules/options.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ local o = {
6464
--move the browser there even if this option is set to false
6565
default_to_working_directory = false,
6666

67+
--when moving up a directory do not stop on empty protocol schemes like `ftp://`
68+
--e.g. moving up from `ftp://localhost/` will move straight to the root instead of `ftp://`
69+
skip_protocol_schemes = true,
70+
6771
--allows custom icons be set for the folder and cursor
6872
--the `\h` character is a hard space to add padding between the symbol and the text
6973
folder_icon = [[{\p1}m 6.52 0 l 1.63 0 b 0.73 0 0.01 0.73 0.01 1.63 l 0 11.41 b 0 12.32 0.73 13.05 1.63 13.05 l 14.68 13.05 b 15.58 13.05 16.31 12.32 16.31 11.41 l 16.31 3.26 b 16.31 2.36 15.58 1.63 14.68 1.63 l 8.15 1.63{\p0}\h]],

0 commit comments

Comments
 (0)