Skip to content

Commit

Permalink
Only repaint when initializing new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nickspoons committed Jul 15, 2022
1 parent 0d84f9c commit 95c0005
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions autoload/OmniSharp/testrunner.vim
Original file line number Diff line number Diff line change
Expand Up @@ -351,18 +351,27 @@ endfunction


function! OmniSharp#testrunner#SetTests(bufferTests) abort
let winid = win_getid()
let hasNew = v:false
for buffer in a:bufferTests
let [sln, assembly, key] = s:utils.getProject(buffer.bufnr)
if !has_key(s:tests, key) || !s:tests[key].visible
let hasNew = v:true
endif
let project = get(s:tests, key, { 'files': {}, 'errors': [] })
let project.visible = 1
let s:tests[key] = project
let filename = fnamemodify(bufname(buffer.bufnr), ':p')
let testfile = get(project.files, filename, { 'tests': {} })
if !get(testfile, 'visible', 0)
let hasNew = v:true
endif
let testfile.visible = 1
let project.files[filename] = testfile
for buffertest in buffer.tests
let name = buffertest.name
if !has_key(testfile.tests, name)
let hasNew = v:true
endif
let test = get(testfile.tests, name, { 'state': 'Not run' })
let testfile.tests[name] = test
let test.name = name
Expand All @@ -373,8 +382,19 @@ function! OmniSharp#testrunner#SetTests(bufferTests) abort
let test.lnum = buffertest.nameRange.Start.Line
endfor
endfor
call s:Open()
call win_gotoid(winid)
let winid = win_getid()
if hasNew
call s:Open()
call win_gotoid(winid)
elseif s:buffer.focus()
for buffer in a:bufferTests
let filename = fnamemodify(bufname(buffer.bufnr), ':p')
let pattern = '^ ' . substitute(filename, '/', '\\/', 'g')
call search(pattern, 'cw')
normal! 5zo
endfor
call win_gotoid(winid)
endif
endfunction


Expand Down Expand Up @@ -433,6 +453,11 @@ function! s:UpdateState(bufnr, state, ...) abort
call setbufvar(s:runner.bufnr, '&modified', 0)
endif
endfor
let winid = win_getid()
if s:buffer.focus()
syn sync fromstart
call win_gotoid(winid)
endif
endfunction

function! OmniSharp#testrunner#StateComplete(location) abort
Expand Down

0 comments on commit 95c0005

Please sign in to comment.