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

Open file only if it's readable

parent 00c10559
No related branches found
No related tags found
No related merge requests found
......@@ -16,23 +16,30 @@ function! Tapi_vimgdb_goto(bufnum, arglist)
let session = s:sessions[session_id]
" Go to source window
noautocmd call win_gotoid(session['source_winid'])
" 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))
try
" Open file if needed
if filename != expand('%:p')
" Do nothing when file is not readable
if !filereadable(filename)
return
endif
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
finally
" Switch back to debugger window
noautocmd call win_gotoid(bufwinid(a:bufnum))
endtry
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