Skip to content

Commit

Permalink
Merge pull request #194 from lambdalisue/mark-children-pre
Browse files Browse the repository at this point in the history
Add "get_child_nodes" on helper.async
  • Loading branch information
lambdalisue authored Sep 6, 2020
2 parents d3d9412 + 7bf1fec commit 2d21376
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
19 changes: 19 additions & 0 deletions autoload/fern/helper/async.vim
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ function! s:async_remark() abort dict
endfunction
let s:async.remark = funcref('s:async_remark')

function! s:async_get_child_nodes(key) abort dict
let helper = self.helper
let fern = helper.fern
let node = fern#internal#node#find(a:key, fern.nodes)
if empty(node)
return s:Promise.reject(printf('failed to find a node %s', a:key))
endif
let Profile = fern#profile#start('fern#helper:helper.async.get_child_nodes')
return s:Promise.resolve()
\.then({ -> fern#internal#node#children(
\ node,
\ fern.provider,
\ fern.source.token,
\ )
\})
\.finally({ -> Profile() })
endfunction
let s:async.get_child_nodes = funcref('s:async_get_child_nodes')

function! s:async_set_mark(key, value) abort dict
let helper = self.helper
let fern = helper.fern
Expand Down
4 changes: 4 additions & 0 deletions doc/fern-develop.txt
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ Following methods are executed asynchronously and return a promise.
.async.remark()
Return a promise to remark the content.

*fern-develop-helper.async.get_child_nodes()*
.async.get_child_nodes({key})
Return a promise which will resolves to child nodes of the {key} node.

*fern-develop-helper.async.set_mark()*
.async.set_mark({key}, {value})
Return a promise to set mark to a node identified by the {key}.
Expand Down
1 change: 1 addition & 0 deletions test/fern/helper.vimspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Describe fern#helper
\ 'sleep',
\ 'redraw',
\ 'remark',
\ 'get_child_nodes',
\ 'set_mark',
\ 'set_hidden',
\ 'set_include',
Expand Down

0 comments on commit 2d21376

Please sign in to comment.