From 8a7d482391f0ef08c144e0ab2d0a28946ca5022b Mon Sep 17 00:00:00 2001 From: Nick Jensen Date: Sat, 16 Jul 2022 22:31:04 +1200 Subject: [PATCH] Add success/failure glyph beside completed tests --- autoload/OmniSharp/testrunner.vim | 16 +++++++++++++--- syntax/omnisharptest.vim | 11 +++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/autoload/OmniSharp/testrunner.vim b/autoload/OmniSharp/testrunner.vim index 84014e707..ab8dd9f7b 100644 --- a/autoload/OmniSharp/testrunner.vim +++ b/autoload/OmniSharp/testrunner.vim @@ -298,7 +298,16 @@ function! s:buffer.painttest(test, lnum) abort endif let lines = [] let state = s:utils.state2char[a:test.state] - call add(lines, printf('%s %s', state, a:test.name)) + let glyph = '' + if state ==# '*' && get(g:, 'OmniSharp_testrunner_glyph', 1) + let glyph = get(g:, 'OmniSharp_testrunner_glyph_passed', '✔') + elseif state ==# '!' && get(g:, 'OmniSharp_testrunner_glyph', 1) + let glyph = get(g:, 'OmniSharp_testrunner_glyph_failed', '✘') + endif + if glyph !=# '' + let glyph = printf('|| %s || ', glyph) + endif + call add(lines, printf('%s %s%s', state, glyph, a:test.name)) if state ==# '-' && !has_key(a:test, 'spintimer') call s:spinner.start(a:test, a:lnum) endif @@ -434,7 +443,7 @@ function! s:UpdateState(bufnr, state, ...) abort let lines = getbufline(s:runner.bufnr, 1, '$') let pattern = '^ ' . substitute(filename, '/', '\\/', 'g') let fileline = match(lines, pattern) + 1 - let pattern = '^[-|*!] ' . testname + let pattern = '^[-|*!] \%(|| .\{-} || \)\?' . testname let testline = match(lines, pattern, fileline) + 1 let patterns = ['^[-|*!] \S', '^__$', '^$'] @@ -593,7 +602,8 @@ function! s:utils.findTest() abort let testline = search(testpattern, 'bcnWz') endif if testline > 0 - let testname = matchlist(getline(testline), '[-|*!] \zs.*$')[0] + let line = getline(testline) + let testname = matchlist(line, '[-|*!] \%(|| .\{-} || \)\?\zs.*$')[0] let projectline = search('^;', 'bcnWz') let projectkey = matchlist(getline(projectline), '^\S\+')[0] let fileline = search('^ \f', 'bcnWz') diff --git a/syntax/omnisharptest.vim b/syntax/omnisharptest.vim index db0c158af..357fd7677 100644 --- a/syntax/omnisharptest.vim +++ b/syntax/omnisharptest.vim @@ -32,8 +32,8 @@ syn match ostFileDivider "^__$" conceal syn match ostStateNotRun "^|.*" contains=ostStatePrefix,ostTestNamespace syn match ostStateRunning "^-.*" contains=ostStatePrefix,ostTestNamespace,ostRunningSuffix -syn match ostStatePassed "^\*.*" contains=ostStatePrefix,ostTestNamespace -syn match ostStateFailed "^!.*" contains=ostStatePrefix,ostTestNamespace +syn match ostStatePassed "^\*.*" contains=ostStatePrefix,ostTestNamespace,ostStatePassedGlyph,ostCompletePrefixDivider +syn match ostStateFailed "^!.*" contains=ostStatePrefix,ostTestNamespace,ostStateFailedGlyph,ostCompletePrefixDivider syn match ostStatePrefix "^[|\*!-]" conceal contained syn match ostTestNamespace "\%(\w\+\.\)*\ze\w\+" conceal contained @@ -41,6 +41,10 @@ syn match ostRunningSuffix " -- .*" contained contains=ostRunningSpinner,ostRun syn match ostRunningSuffixDivider " \zs--" conceal contained syn match ostRunningSpinner " -- \zs.*" contained +syn match ostStatePassedGlyph "\%(|| \)\@<=.\{-}\ze || " contained +syn match ostStateFailedGlyph "\%(|| \)\@<=.\{-}\ze || " contained +syn match ostCompletePrefixDivider "|| " conceal contained + syn region ostFailure start="^>" end="^[^>]"me=s-1 contains=ostFailurePrefix,ostStackLoc,ostStackNoLoc fold syn match ostFailurePrefix "^>" conceal contained syn region ostStackLoc start=" __ "hs=e+1 end=" __ "he=e-1 contains=ostStackFile,ostStackDelimiter,ostStackNamespace contained keepend @@ -66,7 +70,9 @@ hi def link ostStateNotRun Comment hi def link ostStateRunning Identifier hi def link ostRunningSpinner Normal hi def link ostStatePassed Title +hi def link ostStatePassedGlyph Title hi def link ostStateFailed WarningMsg +hi def link ostStateFailedGlyph WarningMsg hi def link ostStackLoc Identifier hi def link ostOutput Comment @@ -78,6 +84,7 @@ hi def link ostFileDivider NonText hi def link ostStatePrefix NonText hi def link ostFailurePrefix NonText hi def link ostRunningSuffixDivider NonText +hi def link ostCompletePrefixDivider NonText hi def link ostStackDelimiter NonText hi def link ostStackFileDelimiter NonText hi def link ostStackNoLocDelimiter NonText