Skip to content

Commit

Permalink
Add uiDone autocmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed May 21, 2024
1 parent d1bd7e4 commit 2215e4d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion autoload/ddu/denops.vim
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function s:init() abort
augroup ddu
autocmd!
autocmd User DenopsPluginPost:ddu let g:ddu#_initialized = v:true
autocmd User Ddu:redraw,Ddu:uiReady :
autocmd User Ddu:redraw,Ddu:uiReady,Ddu:uiDone :
augroup END

let g:ddu#_started = reltime()
Expand Down
1 change: 1 addition & 0 deletions denops/ddu/base/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export abstract class BaseUi<
name = "";
path = "";
isInitialized = false;
prevDone = false;

onInit(_args: OnInitArguments<Params>): void | Promise<void> {}
onBeforeAction(
Expand Down
6 changes: 6 additions & 0 deletions denops/ddu/ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,12 @@ export async function uiRedraw<
// NOTE: UI window is generated.
await denops.cmd("doautocmd <nomodeline> User Ddu:uiReady");
}

if (!ui.prevDone && context.done) {
await denops.cmd("doautocmd <nomodeline> User Ddu:uiDone");
}

ui.prevDone = context.done;
} catch (e: unknown) {
if (e instanceof Error && e.message.includes(" E523: ")) {
// NOTE: It may be called on invalid state
Expand Down
7 changes: 6 additions & 1 deletion doc/ddu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,12 @@ ddu.vim defines some |User| autocmds.
Ddu:redraw
Called after |ddu-ui-attribute-redraw| is called.

*ddu-autocmd-Ddu:uiReady*
*ddu-autocmd-Ddu:uiDone*
Ddu:uiDone
Called after all items are gathered in
|ddu-ui-attribute-redraw|.

*ddu-autocmd-Ddu:uiReady*
Ddu:uiReady
Called after UI window is created in
|ddu-ui-attribute-redraw|.
Expand Down

0 comments on commit 2215e4d

Please sign in to comment.