From fde02e1c12735fd86cf90d4819f54822bc90f060 Mon Sep 17 00:00:00 2001 From: Alisue Date: Tue, 25 Jun 2024 01:48:57 +0900 Subject: [PATCH 1/2] :+1: Forcibly show info/warn/error messages block to the user Users may not realize that there are info/warn/error messages in the message history. This commit forcibly shows the messages to the user when the messages are posted with `console.info/warn/error` functions in Denops side. --- autoload/denops/_internal/echo.vim | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/autoload/denops/_internal/echo.vim b/autoload/denops/_internal/echo.vim index 704bdced..f44c44f3 100644 --- a/autoload/denops/_internal/echo.vim +++ b/autoload/denops/_internal/echo.vim @@ -1,3 +1,8 @@ +const s:DELAYED_INTERVAL = 100 + +let s:delayed_messages = [] +let s:delayed_timer = 0 + function! denops#_internal#echo#deprecate(...) abort if g:denops#disable_deprecation_warning_message return @@ -17,15 +22,15 @@ function! denops#_internal#echo#debug(...) abort endfunction function! denops#_internal#echo#info(...) abort - call s:echomsg('Title', a:000) + call s:echomsg_delay('Title', a:000) endfunction function! denops#_internal#echo#warn(...) abort - call s:echomsg('WarningMsg', a:000) + call s:echomsg_delay('WarningMsg', a:000) endfunction function! denops#_internal#echo#error(...) abort - call s:echomsg('ErrorMsg', a:000) + call s:echomsg_delay('ErrorMsg', a:000) endfunction function! s:echomsg(hl, msg) abort @@ -35,3 +40,21 @@ function! s:echomsg(hl, msg) abort endfor echohl None endfunction + +function! s:echomsg_delay(hl, msg) abort + call add(s:delayed_messages, [a:hl, a:msg]) + call timer_stop(s:delayed_timer) + let s:delayed_timer = timer_start(s:DELAYED_INTERVAL, {-> s:echomsg_batch()}) +endfunction + +function! s:echomsg_batch() abort + let l:counter = 0 + for l:message in s:delayed_messages + call s:echomsg(l:message[0], l:message[1]) + let l:counter += len(split(join(l:message[1]), '\n')) + endfor + let s:delayed_timer = 0 + let s:delayed_messages = [] + " Forcibly show the messages to the user + call feedkeys(printf(":\%dmessages\", l:counter), 'nt') +endfunction From 28414d13ddc3a2fff43edc8add1a6bc351bc39f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=9Blisue=20=28Ali=20sue=E3=83=BB=E3=81=82=E3=82=8A?= =?UTF-8?q?=E3=81=99=E3=81=88=29?= Date: Tue, 25 Jun 2024 15:03:28 +0900 Subject: [PATCH 2/2] Update autoload/denops/_internal/echo.vim Co-authored-by: Milly --- autoload/denops/_internal/echo.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/denops/_internal/echo.vim b/autoload/denops/_internal/echo.vim index f44c44f3..a5b6d56e 100644 --- a/autoload/denops/_internal/echo.vim +++ b/autoload/denops/_internal/echo.vim @@ -56,5 +56,5 @@ function! s:echomsg_batch() abort let s:delayed_timer = 0 let s:delayed_messages = [] " Forcibly show the messages to the user - call feedkeys(printf(":\%dmessages\", l:counter), 'nt') + call feedkeys(printf("\%dmessages\", l:counter), 'n') endfunction