Skip to content

Commit

Permalink
fix: returns rejected promise instead throw error when call provider …
Browse files Browse the repository at this point in the history
…methods (#500)

* fix: returns rejected promise instead throw error when call provider methods

* fix: avoid error of `readdir()`
  • Loading branch information
Milly committed May 7, 2024
1 parent a1f29b3 commit cc8ca2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions autoload/fern/internal/node.vim
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ function! fern#internal#node#parent(node, provider, token, ...) abort
endif
let l:Profile = fern#profile#start('fern#internal#node#parent')
let l:Done = fern#internal#node#process(a:node)
let p = a:provider.get_parent(a:node, a:token)
let p = s:Promise.new({ resolve ->
\ resolve(a:provider.get_parent(a:node, a:token))
\ })
\.then({ n -> s:new(n, {
\ '__key': [],
\ '__owner': v:null,
Expand Down Expand Up @@ -91,7 +93,9 @@ function! fern#internal#node#children(node, provider, token, ...) abort
endif
let l:Profile = fern#profile#start('fern#internal#node#children')
let l:Done = fern#internal#node#process(a:node)
let p = a:provider.get_children(a:node, a:token)
let p = s:Promise.new({ resolve ->
\ resolve(a:provider.get_children(a:node, a:token))
\ })
\.then(s:AsyncLambda.map_f({ n ->
\ s:new(n, {
\ '__key': a:node.__key + [n.name],
Expand Down
3 changes: 2 additions & 1 deletion autoload/fern/scheme/file/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ if exists('*readdir')
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))
silent! let children = readdir(a:path)
return s:Promise.resolve(children)
\.then(s:AsyncLambda.map_f({ v -> p . v }))
\.finally({ -> Profile() })
endfunction
Expand Down

0 comments on commit cc8ca2b

Please sign in to comment.