@@ -5,16 +5,102 @@ set cpoptions&vim
55let s: current = get (s: , ' current' , {})
66let s: runner = get (s: , ' runner' , {})
77
8+
9+ function ! OmniSharp#testrunner#Debug () abort
10+ endfunction
11+
12+
813function ! OmniSharp#testrunner#Init (buffers ) abort
914 let s: current .log = []
1015 let s: current .singlebuffer = len (a: buffers ) == 1 ? a: buffers [0 ] : -1
1116 let s: current .testnames = {}
1217endfunction
1318
19+
1420function ! OmniSharp#testrunner#Log (message) abort
1521 call extend (s: current .log , a: message )
1622endfunction
1723
24+
25+ function ! OmniSharp#testrunner#Run () abort
26+ endfunction
27+
28+
29+ function ! OmniSharp#testrunner#Navigate () abort
30+ if &filetype !=# ' omnisharptest' | return | endif
31+ let bufnr = -1
32+ let filename = ' '
33+ let lnum = -1
34+ let col = -1
35+ let line = getline (' .' )
36+ if line = ~# ' ^\a'
37+ " Project selected - do nothing
38+ elseif line = ~# ' ^ \f'
39+ " File selected
40+ let filename = trim (line )
41+ let bufnr = bufnr (filename)
42+ else
43+ " Stack trace with valid location (filename and possible line number)
44+ let parsed = matchlist (line , ' ^> \+__ .* ___ \(.*\) __ \%(line \(\d\+\)\)\?$' )
45+ if len (parsed)
46+ let filename = parsed[1 ]
47+ if parsed[2 ] !=# ' '
48+ let lnum = str2nr (parsed[2 ])
49+ endif
50+ endif
51+ if filename == # ' '
52+ " Search for test
53+ let testpattern = ' [-|*!] \S'
54+ if line = ~# testpattern
55+ let testline = line (' .' )
56+ else
57+ let testline = search (testpattern, ' bcnWz' )
58+ endif
59+ if testline > 0
60+ let testname = matchlist (getline (testline), ' [-|*!] \zs.*$' )[0 ]
61+ let projectline = search (' ^\a' , ' bcnWz' )
62+ let projectname = matchlist (getline (projectline), ' ^\S\+' )[0 ]
63+ let fileline = search (' ^ \f' , ' bcnWz' )
64+ let filename = matchlist (getline (fileline), ' ^ \zs.*$' )[0 ]
65+ let filename = fnamemodify (filename, ' :p' )
66+ for sln_or_dir in OmniSharp#proc#ListRunningJobs ()
67+ let job = OmniSharp#proc#GetJob (sln_or_dir)
68+ if has_key (job, ' tests' ) && has_key (job.tests, projectname)
69+ let lnum = job.tests[projectname][filename][testname].lnum
70+ break
71+ endif
72+ endfor
73+ endif
74+ endif
75+ endif
76+ if bufnr == -1
77+ if filename !=# ' '
78+ let bufnr = bufnr (filename)
79+ if bufnr == -1
80+ let bufnr = bufadd (filename)
81+ call bufload (bufnr )
82+ endif
83+ endif
84+ if bufnr == -1 | return | endif
85+ endif
86+ for winnr in range (1 , winnr (' $' ))
87+ if winbufnr (winnr ) == bufnr
88+ call win_gotoid (win_getid (winnr ))
89+ break
90+ endif
91+ endfor
92+ if bufnr () != bufnr
93+ execute ' aboveleft split' filename
94+ endif
95+ if lnum != -1
96+ call cursor (lnum, max ([col , 0 ]))
97+ if col == -1
98+ normal ! ^
99+ endif
100+ endif
101+ endfunction
102+
103+
18104function ! OmniSharp#testrunner#Open () abort
19105 if ! OmniSharp#actions#test#Validate () | return | endif
20106 call s: Open ()
0 commit comments