Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show error line body #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions autoload/exception.vim
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function! exception#trace() abort
continue
endif

let src = fnamemodify(matchstr(verb[1], 'Last set from \zs.\+'), ':p')
let src = fnamemodify(matchstr(verb[1], 'Last set from \zs.\+\ze\%( line \d\+\)'), ':p')
if !filereadable(src)
continue
endif
Expand All @@ -68,19 +68,31 @@ function! exception#trace() abort
endif
let pat .= func.'\>'

for line in readfile(src)
let lnum += 1
let function_offset = 0
let function_found = 0
let line_body = ''

for [index, line] in items(readfile(src))
if !function_found
let function_offset += 1
endif

if line =~# pat
let function_found = 1
endif

if lnum + function_offset == index + 1
let line_body = trim(line)
break
endif
endfor

if !empty(src) && !empty(func)
let fname = fnamemodify(src, ':.')
call add(errlist, {
\ 'text': printf('%*s. %s', nw, '#'.i, t),
\ 'text': printf('%*s. %s: %s', nw, '#'.i, t, line_body),
\ 'filename': fname,
\ 'lnum': lnum,
\ 'lnum': function_offset + lnum,
\ 'type': 'I',
\ })
endif
Expand Down