Skip to content

Commit

Permalink
Avoid :redir inside execute()
Browse files Browse the repository at this point in the history
This was happening when starting vim with `let g:gitgutter_log = 1`
and generated E930.
  • Loading branch information
airblade committed Jun 3, 2023
1 parent 538fba9 commit 621b9e7
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions autoload/gitgutter/debug.vim
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,21 @@ function! gitgutter#debug#log(message, ...) abort
endif
endif

execute 'redir >> '.s:log_file
if s:new_log_session
let s:start = reltime()
silent echo "\n==== start log session ===="
endif
if s:new_log_session
let s:start = reltime()
call writefile(['==== start log session ===='], s:log_file, 'a')
endif

let elapsed = reltimestr(reltime(s:start)).' '
silent echo ''
" callers excluding this function
silent echo elapsed.expand('<sfile>')[:-22].':'
silent echo elapsed.s:format_for_log(a:message)
if a:0 && !empty(a:1)
for msg in a:000
silent echo elapsed.s:format_for_log(msg)
endfor
endif
redir END
let elapsed = reltimestr(reltime(s:start)).' '
call writefile([''], s:log_file, 'a')
" callers excluding this function
call writefile([elapsed.expand('<sfile>')[:-22].':'], s:log_file, 'a')
call writefile([elapsed.s:format_for_log(a:message)], s:log_file, 'a')
if a:0 && !empty(a:1)
for msg in a:000
call writefile([elapsed.s:format_for_log(msg)], s:log_file, 'a')
endfor
endif

let s:new_log_session = 0
endif
Expand Down

0 comments on commit 621b9e7

Please sign in to comment.