Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👍 Forcibly show info/warn/error messages block to the user (RFC) #377

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions autoload/denops/_internal/echo.vim
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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("\<Cmd>%dmessages\<CR>", l:counter), 'n')
endfunction