@@ -5,7 +5,7 @@ let s:state2char = {
5
5
\ ' Not run' : ' |' ,
6
6
\ ' Running' : ' -' ,
7
7
\ ' Passed' : ' *' ,
8
- \ ' Failed' : ' # '
8
+ \ ' Failed' : ' ! '
9
9
\}
10
10
11
11
function ! OmniSharp#testrunner#Open () abort
@@ -36,38 +36,61 @@ function s:Open() abort
36
36
if &filetype !=# ft
37
37
botright new
38
38
endif
39
-
39
+ let s: testrunner_bufnr = bufnr ()
40
40
silent setlocal noswapfile signcolumn = no conceallevel=3 concealcursor=nv
41
+ setlocal comments = :# commentstring = #\ % s
41
42
set bufhidden = hide
42
43
let &filetype = ft
43
44
execute ' file' title
44
45
call s: Paint ()
45
46
endfunction
46
47
48
+ function ! OmniSharp#testrunner#Repaint () abort
49
+ " Check that the test runner has been initialised and is still a loaded buffer
50
+ if ! exists (' s:testrunner_bufnr' ) | return | endif
51
+ if getbufvar (s: testrunner_bufnr , ' &ft' ) !=# ' omnisharptest' | return | endif
52
+ " If the buffer is listed in a window in the current tab, then focus it
53
+ for winnr in range (1 , winnr (' $' ))
54
+ if winbufnr (winnr ) == s: testrunner_bufnr
55
+ let l: winid = win_getid ()
56
+ call win_gotoid (win_getid (winnr ))
57
+ break
58
+ endif
59
+ endfor
60
+ call s: Paint ()
61
+ if exists (' l:winid' )
62
+ call win_gotoid (l: winid )
63
+ endif
64
+ endfunction
65
+
47
66
function ! s: Paint () abort
48
- setlocal modifiable
49
- let winview = winsaveview ()
50
- 0 ,$delete _
51
- put = ' OmniSharp Test Runner'
52
- 0 delete _
53
- put = ' '
67
+ let lines = []
68
+ call add (lines , repeat (' =' , 80 ))
69
+ call add (lines , ' OmniSharp Test Runner' )
70
+ call add (lines , repeat (' =' , 80 ))
71
+ call add (lines , ' ' )
54
72
55
73
for sln_or_dir in OmniSharp#proc#ListRunningJobs ()
56
- put = fnamemodify (sln_or_dir, ' :t' )
74
+ call add ( lines , fnamemodify (sln_or_dir, ' :t' ) )
57
75
let job = OmniSharp#proc#GetJob (sln_or_dir)
58
76
if ! has_key (job, ' tests' ) | continue | endif
59
77
for testfile in keys (job.tests)
60
- put = ' ' . fnamemodify (testfile, ' :.' )
78
+ call add ( lines , ' ' . fnamemodify (testfile, ' :.' ) )
61
79
for name in keys (job.tests[testfile])
62
80
let test = job.tests[testfile][name]
63
- put = printf (' %s %s' , s: state2char [test.state ], name)
81
+ call add ( lines , printf (' %s %s' , s: state2char [test.state ], name) )
64
82
endfor
65
83
endfor
66
- put = ' '
84
+ call add ( lines , ' ' )
67
85
endfor
68
86
69
- call winrestview (winview)
70
- setlocal nomodifiable nomodified
87
+ if bufnr () == s: testrunner_bufnr | let winview = winsaveview () | endif
88
+ call setbufvar (s: testrunner_bufnr , ' &modifiable' , 1 )
89
+ call deletebufline (s: testrunner_bufnr , 1 , ' $' )
90
+ call setbufline (s: testrunner_bufnr , 1 , lines )
91
+ call setbufvar (s: testrunner_bufnr , ' &modifiable' , 0 )
92
+ call setbufvar (s: testrunner_bufnr , ' &modified' , 0 )
93
+ if bufnr () == s: testrunner_bufnr |call winrestview (winview) | endif
71
94
endfunction
72
95
73
96
function ! OmniSharp#testrunner#SetTests (bufferTests) abort
0 commit comments