Skip to content
Snippets Groups Projects
Commit 00c10559 authored by Moritz Sichert's avatar Moritz Sichert
Browse files

Only jump to current line if it's not visible

parent bc0e59f3
No related branches found
No related tags found
No related merge requests found
......@@ -14,15 +14,23 @@ function! Tapi_vimgdb_goto(bufnum, arglist)
let filename = a:arglist[1]
let line = a:arglist[2]
let session = s:sessions[session_id]
" Go to source window and jump to current line
" Go to source window
noautocmd call win_gotoid(session['source_winid'])
execute 'edit' fnameescape(filename)
execute 'normal!' line . 'G'
" Open file if needed
if filename != expand('%:p')
execute 'edit' fnameescape(filename)
endif
" Update highlighted line
if session['current_line_matchid'] != -1
call matchdelete(session['current_line_matchid'])
endif
let session['current_line_matchid'] = matchaddpos('VimgdbCurrentLine', [line])
" Jump to current line if its not visible
let first_visible = line('w0')
let last_visible = line('w$')
if last_visible > first_visible && (line < first_visible || line > last_visible)
execute 'keepjumps normal!' line . 'G'
endif
" Switch back to debugger window
noautocmd call win_gotoid(bufwinid(a:bufnum))
endfunction
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment