Skip to content

Commit 4c1f24b

Browse files
authored
Merge pull request #2507 from bhcleek/lsp/fix-clean
lsp: fix CleanWorkspaces
2 parents 6904ded + 21e4524 commit 4c1f24b

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ install:
1414
- ./scripts/install-vim $VIM_VERSION
1515
- |
1616
if [ "$ENV" = "vimlint" ]; then
17-
pip install vim-vint covimerage codecov pathlib
17+
pip install vim-vint covimerage==0.1.6 codecov pathlib
1818
else
19-
pip install --user vim-vint covimerage codecov pathlib
19+
pip install --user vim-vint covimerage==0.1.6 codecov pathlib
2020
fi
2121
script:
2222
- ./scripts/$SCRIPT $VIM_VERSION

autoload/go/config_test.vim

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func! Test_SetBuildTags() abort
7474
let l:lsplog = getbufline('__GOLSP_LOG__', 1, '$')
7575

7676
finally
77+
call go#config#SetBuildTags('')
7778
unlet g:go_def_mode
7879
endtry
7980
endfunc

autoload/go/lsp.vim

+18-2
Original file line numberDiff line numberDiff line change
@@ -746,13 +746,17 @@ function! go#lsp#CleanWorkspaces() abort
746746
let l:missing = []
747747
for l:dir in l:lsp.workspaceDirectories
748748
if !isdirectory(l:dir)
749-
let l:dir = add(l:missing, l:dir)
749+
let l:missing = add(l:missing, l:dir)
750750
call remove(l:lsp.workspaceDirectories, l:i)
751751
continue
752752
endif
753753
let l:i += 1
754754
endfor
755755

756+
if len(l:missing) == 0
757+
return 0
758+
endif
759+
756760
let l:state = s:newHandlerState('')
757761
let l:state.handleResult = funcref('s:noop')
758762
let l:msg = go#lsp#message#ChangeWorkspaceFolders([], l:missing)
@@ -789,14 +793,26 @@ function! go#lsp#DebugBrowser() abort
789793
call go#util#OpenBrowser(printf('http://localhost:%d', l:port))
790794
endfunction
791795

796+
function! go#lsp#Exit() abort
797+
call s:exit(0)
798+
endfunction
799+
792800
function! go#lsp#Restart() abort
801+
call s:exit(1)
802+
endfunction
803+
804+
function! s:exit(restart) abort
793805
if !go#util#has_job() || len(s:lspfactory) == 0 || !has_key(s:lspfactory, 'current')
794806
return
795807
endif
796808

797809
let l:lsp = s:lspfactory.get()
798810

799-
let l:lsp.restarting = 1
811+
" reset the factory so that future requests don't use the same instance of
812+
" gopls.
813+
call s:lspfactory.reset()
814+
815+
let l:lsp.restarting = a:restart
800816

801817
let l:state = s:newHandlerState('exit')
802818

scripts/runtest.vim

+5-1
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,16 @@ for s:test in sort(s:tests)
7474
let v:errors += [v:exception]
7575
endtry
7676

77+
let s:elapsed_time = substitute(reltimestr(reltime(s:started)), '^\s*\(.\{-}\)\s*$', '\1', '')
78+
7779
" Restore GOPATH after each test.
7880
let $GOPATH = s:gopath
7981
" Restore the working directory after each test.
8082
execute s:cd . s:dir
8183

82-
let s:elapsed_time = substitute(reltimestr(reltime(s:started)), '^\s*\(.\{-}\)\s*$', '\1', '')
84+
" exit gopls after each test
85+
call go#lsp#Exit()
86+
8387
let s:done += 1
8488

8589
if len(v:errors) > 0

0 commit comments

Comments
 (0)