Skip to content

Commit 561a662

Browse files
author
Minh-Tam TRAN
committed
Prioritize already-running-sln_or_dirs over parent-folders-exploration when editing new buffers
1 parent 60fd0c6 commit 561a662

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

autoload/OmniSharp.vim

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,13 @@ endfunction
237237
function! OmniSharp#FindSolutionOrDir(...) abort
238238
let interactive = a:0 ? a:1 : 1
239239
let bufnr = a:0 > 1 ? a:2 : bufnr('%')
240-
if empty(getbufvar(bufnr, 'OmniSharp_buf_server'))
240+
let cache = getbufvar(bufnr, 'OmniSharp_buf_server')
241+
if empty(cache) || index(OmniSharp#proc#ListJobs(), cache) < 0
241242
try
242243
let sln = s:FindSolution(interactive, bufnr)
243-
call setbufvar(bufnr, 'OmniSharp_buf_server', sln)
244+
if sln != cache
245+
call setbufvar(bufnr, 'OmniSharp_buf_server', sln)
246+
endif
244247
catch
245248
return ''
246249
endtry
@@ -378,11 +381,11 @@ endfunction
378381

379382

380383
function! s:FindSolution(interactive, bufnr) abort
381-
let solution_files = s:FindSolutionsFiles(a:bufnr)
382-
if empty(solution_files)
383-
" This file has no parent solution, so check for running solutions
384-
return s:FindRunningServerForBuffer(a:bufnr)
384+
let running_server_for_buffer = s:FindRunningServerForBuffer(a:bufnr)
385+
if !empty(running_server_for_buffer)
386+
return running_server_for_buffer
385387
endif
388+
let solution_files = s:FindSolutionsFiles(a:bufnr)
386389

387390
if len(solution_files) == 1
388391
return solution_files[0]

0 commit comments

Comments
 (0)