Skip to content

Commit

Permalink
lsp: improve debug logging
Browse files Browse the repository at this point in the history
* Use win_execute instead of win_gotoid when possible to avoid problems
  with textlock that can occur when completion is in progress. This
  isn't a full solution, so the retry has to remain in case the debug
  window is being created for the first time while completion is in
  progress. However, in nearly all other cases, the debug window will be
  able to be changed without making it the active window.
* Set the log's fileencoding to utf-8 so that multibyte characters will
  be displayed correctly.
  • Loading branch information
bhcleek committed Feb 25, 2024
1 parent 6857f3e commit b336ecc
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions autoload/go/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,7 @@ function! s:debugasync(timer) abort
silent file `='__GOLSP_LOG__'`
setlocal buftype=nofile bufhidden=wipe nomodified nobuflisted noswapfile nowrap nonumber nocursorline
setlocal filetype=golsplog
setlocal fileencoding=utf-8
call win_gotoid(l:winid)
endif

Expand All @@ -1380,11 +1381,8 @@ function! s:debugasync(timer) abort
call appendbufline(l:name, '$', split(l:data, "\r\n"))
endfor

" TODO(bc): how to move the window's cursor position without switching
" to the window?
call win_gotoid(l:logwinid)
normal! G
call win_gotoid(l:winid)
" Move the window's cursor position without switching to the window
call win_execute(l:logwinid, 'normal! G')
call setbufvar(l:name, '&modifiable', 0)
finally
endtry
Expand Down

0 comments on commit b336ecc

Please sign in to comment.