From bb469ce3e7c9ca481b1d49122ee7e0836e9d585e Mon Sep 17 00:00:00 2001 From: Alisue Date: Fri, 11 Feb 2022 18:27:34 +0900 Subject: [PATCH] Fix duplicated backslashes in `_path` on Windows Close #391 --- autoload/fern/scheme/file/provider.vim | 2 +- autoload/fern/scheme/file/util.vim | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/autoload/fern/scheme/file/provider.vim b/autoload/fern/scheme/file/provider.vim index 705ed10d..828f1839 100644 --- a/autoload/fern/scheme/file/provider.vim +++ b/autoload/fern/scheme/file/provider.vim @@ -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 diff --git a/autoload/fern/scheme/file/util.vim b/autoload/fern/scheme/file/util.vim index ce47fbbf..9a0e8e3f 100644 --- a/autoload/fern/scheme/file/util.vim +++ b/autoload/fern/scheme/file/util.vim @@ -36,8 +36,9 @@ 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 @@ -45,8 +46,9 @@ 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 }, []))