Skip to content

Commit c7be4c7

Browse files
committed
Only try to record for files
Plugins like dirvish and netrw let you "edit" directories to see what's in them. Using them triggers a panic in gtm, so don't do that. panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x20 pc=0x64d57e] Also output the result of calling gtm so users can see whether it's actually a path failure. Otherwise, gtm-vim's message may be confusing (it led me astray).
1 parent ebd33f7 commit c7be4c7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

plugin/gtm.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ let s:gtm_plugin_status = ''
5252
function! s:record()
5353
let fpath = expand('%:p')
5454
" record if file path has changed or last update is greater than update_interval
55-
if s:last_file != fpath || localtime() - s:last_update > s:update_interval
55+
if filereadable(fpath) && (s:last_file != fpath || localtime() - s:last_update > s:update_interval)
5656
let s:cmd = (g:gtm_plugin_status_enabled == 1 ? 'gtm record --status' : 'gtm record')
5757
let output=system(s:cmd . ' ' . shellescape(fpath))
5858
if v:shell_error
5959
echoerr s:no_gtm_err
60+
echom "Trying to record file: ".. fpath
61+
echom "With command: ".. s:cmd .. ' ' .. shellescape(fpath)
62+
echom output
6063
else
6164
let s:gtm_plugin_status = (g:gtm_plugin_status_enabled ? substitute(output, '\n\+$', '', '') : '')
6265
endif

0 commit comments

Comments
 (0)