Skip to content

Commit

Permalink
Merge pull request #392 from lambdalisue/fix-391
Browse files Browse the repository at this point in the history
Fix duplicated backslashes in `_path` on Windows
  • Loading branch information
lambdalisue committed Feb 12, 2022
2 parents d415fce + bb469ce commit 89ebaf5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion autoload/fern/scheme/file/provider.vim
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ endif

if s:is_windows
let s:windows_drive_nodes = fern#scheme#file#util#list_drives(s:CancellationToken.none)
\.then(s:AsyncLambda.map_f({ v -> s:safe(funcref('s:node', [v . '\'])) }))
\.then(s:AsyncLambda.map_f({ v -> s:safe(funcref('s:node', [v])) }))
\.then(s:AsyncLambda.filter_f({ v -> !empty(v) }))
endif

Expand Down
8 changes: 5 additions & 3 deletions autoload/fern/scheme/file/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,19 @@ if exists('*readdir')
function! fern#scheme#file#util#list_entries_readdir(path, ...) abort
let l:Profile = fern#profile#start('fern#scheme#file#util#list_entries_readdir')
let s = s:is_windows ? '\' : '/'
let p = a:path[-1:] ==# s ? a:path : (a:path . s)
return s:Promise.resolve(readdir(a:path))
\.then(s:AsyncLambda.map_f({ v -> a:path . s . v }))
\.then(s:AsyncLambda.map_f({ v -> p . v }))
\.finally({ -> Profile() })
endfunction
endif

function! fern#scheme#file#util#list_entries_glob(path, ...) abort
let l:Profile = fern#profile#start('fern#scheme#file#util#list_entries_glob')
let s = s:is_windows ? '\' : '/'
let a = s:Promise.resolve(glob(a:path . s . '*', 1, 1, 1))
let b = s:Promise.resolve(glob(a:path . s . '.*', 1, 1, 1))
let p = a:path[-1:] ==# s ? a:path : (a:path . s)
let a = s:Promise.resolve(glob(p . '*', 1, 1, 1))
let b = s:Promise.resolve(glob(p . '.*', 1, 1, 1))
\.then(s:AsyncLambda.filter_f({ v -> v[-2:] !=# s . '.' && v[-3:] !=# s . '..' }))
return s:Promise.all([a, b])
\.then(s:AsyncLambda.reduce_f({ a, v -> a + v }, []))
Expand Down

0 comments on commit 89ebaf5

Please sign in to comment.