Skip to content

Commit cc8ca2b

Browse files
authored
fix: returns rejected promise instead throw error when call provider methods (#500)
* fix: returns rejected promise instead throw error when call provider methods * fix: avoid error of `readdir()`
1 parent a1f29b3 commit cc8ca2b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

autoload/fern/internal/node.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ function! fern#internal#node#parent(node, provider, token, ...) abort
6060
endif
6161
let l:Profile = fern#profile#start('fern#internal#node#parent')
6262
let l:Done = fern#internal#node#process(a:node)
63-
let p = a:provider.get_parent(a:node, a:token)
63+
let p = s:Promise.new({ resolve ->
64+
\ resolve(a:provider.get_parent(a:node, a:token))
65+
\ })
6466
\.then({ n -> s:new(n, {
6567
\ '__key': [],
6668
\ '__owner': v:null,
@@ -91,7 +93,9 @@ function! fern#internal#node#children(node, provider, token, ...) abort
9193
endif
9294
let l:Profile = fern#profile#start('fern#internal#node#children')
9395
let l:Done = fern#internal#node#process(a:node)
94-
let p = a:provider.get_children(a:node, a:token)
96+
let p = s:Promise.new({ resolve ->
97+
\ resolve(a:provider.get_children(a:node, a:token))
98+
\ })
9599
\.then(s:AsyncLambda.map_f({ n ->
96100
\ s:new(n, {
97101
\ '__key': a:node.__key + [n.name],

autoload/fern/scheme/file/util.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ if exists('*readdir')
3737
let l:Profile = fern#profile#start('fern#scheme#file#util#list_entries_readdir')
3838
let s = s:is_windows ? '\' : '/'
3939
let p = a:path[-1:] ==# s ? a:path : (a:path . s)
40-
return s:Promise.resolve(readdir(a:path))
40+
silent! let children = readdir(a:path)
41+
return s:Promise.resolve(children)
4142
\.then(s:AsyncLambda.map_f({ v -> p . v }))
4243
\.finally({ -> Profile() })
4344
endfunction

0 commit comments

Comments
 (0)