vim-patch:9.0.2064: cannot use buffer-number for errorformat (#25782)

Problem:  cannot use buffer-number for errorformat
Solution: add support for parsing a buffer number using '%b' in
          'errorformat'

closes: vim/vim#13419

b731800522

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
zeertzjq
2023-10-26 07:42:29 +08:00
committed by GitHub
parent bfe8a39512
commit f2fc44550f
3 changed files with 90 additions and 16 deletions

View File

@@ -6320,4 +6320,53 @@ func Test_quickfix_buffer_contents()
call setqflist([], 'f')
endfunc
" Test for "%b" in "errorformat"
func Test_efm_format_b()
call setqflist([], 'f')
new
call setline(1, ['1: abc', '1: def', '1: ghi'])
let b1 = bufnr()
new
call setline(1, ['2: abc', '2: def', '2: ghi'])
let b2 = bufnr()
new
call setline(1, ['3: abc', '3: def', '3: ghi'])
let b3 = bufnr()
new
let lines =<< trim eval END
{b1}:1:1
{b2}:2:2
{b3}:3:3
END
call setqflist([], ' ', #{lines: lines, efm: '%b:%l:%c'})
cfirst
call assert_equal([b1, 1, 1], [bufnr(), line('.'), col('.')])
cnext
call assert_equal([b2, 2, 2], [bufnr(), line('.'), col('.')])
cnext
call assert_equal([b3, 3, 3], [bufnr(), line('.'), col('.')])
enew!
" Use a non-existing buffer
let lines =<< trim eval END
9991:1:1:m1
9992:2:2:m2
{b3}:3:3:m3
END
call setqflist([], ' ', #{lines: lines, efm: '%b:%l:%c:%m'})
cfirst | cnext
call assert_equal([b3, 3, 3], [bufnr(), line('.'), col('.')])
" Lines with non-existing buffer numbers should be used as non-error lines
call assert_equal([
\ #{lnum: 0, bufnr: 0, end_lnum: 0, pattern: '', valid: 0, vcol: 0, nr: -1,
\ module: '', type: '', end_col: 0, col: 0, text: '9991:1:1:m1'},
\ #{lnum: 0, bufnr: 0, end_lnum: 0, pattern: '', valid: 0, vcol: 0, nr: -1,
\ module: '', type: '', end_col: 0, col: 0, text: '9992:2:2:m2'},
\ #{lnum: 3, bufnr: b3, end_lnum: 0, pattern: '', valid: 1, vcol: 0,
\ nr: -1, module: '', type: '', end_col: 0, col: 3, text: 'm3'}],
\ getqflist())
%bw!
call setqflist([], 'f')
endfunc
" vim: shiftwidth=2 sts=2 expandtab