Skip to content

Commit

Permalink
Given a solution and its projects, when starting the server, kill run…
Browse files Browse the repository at this point in the history
…ning servers whose scope is one of the solution's projects, since it is already covered by the solution server
  • Loading branch information
Minh-Tam TRAN committed Jul 14, 2021
1 parent 49f5626 commit 2ce53e4
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions autoload/OmniSharp/actions/workspace.vim
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,24 @@ function! s:ProjectsRH(job, response) abort
endif

let projectFolders = mapnew(projects, {_,p -> fnamemodify(p.path, ':p:h') })
for i in filter(range(1, bufnr('$')), {_,x -> bufexists(x) && !empty(getbufvar(x, "OmniSharp_host"))})
for i in filter(range(1, bufnr('$')), {_,x -> bufexists(x) && !empty(getbufvar(x, "OmniSharp_host")) && getbufvar(x, "OmniSharp_host").sln_or_dir != a:job.sln_or_dir})
let host = getbufvar(i, "OmniSharp_host")
if index(projectFolders, host.sln_or_dir) < 0 || !host.initialized
let filePath = fnamemodify(bufname(i), ':p')
for projectFolder in projectFolders
if stridx(filePath, projectFolder) == 0
let host.sln_or_dir = a:job.sln_or_dir
break
endif
endfor
endif
let filePath = fnamemodify(bufname(i), ':p')
for projectFolder in projectFolders
if stridx(filePath, projectFolder) == 0
let host.sln_or_dir = a:job.sln_or_dir
break
endif
endfor
endfor

if a:job.sln_or_dir =~ '\.sln$'
for running in OmniSharp#proc#ListRunningJobs()
if index(projectFolders, running) >= 0
call OmniSharp#StopServer(running)
endif
endfor
endif
endfunction

let &cpoptions = s:save_cpo
Expand Down

0 comments on commit 2ce53e4

Please sign in to comment.