Skip to content

Commit c3d450e

Browse files
authored
Disable Sy if an active buffer is now "skippable" (mhinz#344)
If a `sy#start()` is called for a buffer that is no longer backed by a file on disk, then disabling Sy avoids peppering the user with extra error messages. Closes mhinz#336
1 parent 2fd4951 commit c3d450e

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

autoload/sy.vim

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,35 @@ function! sy#start(...) abort
4040
elseif has('vim_starting')
4141
call sy#verbose("Don't run Sy more than once during startup.")
4242
return
43-
elseif empty(sy.vcs)
44-
if get(sy, 'retry')
45-
let sy.retry = 0
46-
call sy#verbose('Redetecting VCS.')
47-
call sy#repo#detect(sy.buffer)
48-
else
49-
if get(sy, 'detecting')
50-
call sy#verbose('Detection is already in progress.')
51-
else
52-
call sy#verbose('No VCS found. Disabling.')
53-
call sy#stop(sy.buffer)
54-
endif
55-
endif
5643
else
57-
for vcs in sy.vcs
58-
let job_id = getbufvar(sy.buffer, 'sy_job_id_'. vcs, 0)
59-
if type(job_id) != type(0) || job_id > 0
60-
call sy#verbose('Update is already in progress.', vcs)
44+
let path = s:get_path(bufnr)
45+
if s:skip(bufnr, path)
46+
call sy#stop()
47+
return
48+
elseif empty(sy.vcs)
49+
if get(sy, 'retry')
50+
let sy.retry = 0
51+
call sy#verbose('Redetecting VCS.')
52+
call sy#repo#detect(sy.buffer)
6153
else
62-
call sy#verbose('Updating signs.', vcs)
63-
call sy#repo#get_diff(sy.buffer, vcs, function('sy#sign#set_signs'))
54+
if get(sy, 'detecting')
55+
call sy#verbose('Detection is already in progress.')
56+
else
57+
call sy#verbose('No VCS found. Disabling.')
58+
call sy#stop(sy.buffer)
59+
endif
6460
endif
65-
endfor
61+
else
62+
for vcs in sy.vcs
63+
let job_id = getbufvar(sy.buffer, 'sy_job_id_'. vcs, 0)
64+
if type(job_id) != type(0) || job_id > 0
65+
call sy#verbose('Update is already in progress.', vcs)
66+
else
67+
call sy#verbose('Updating signs.', vcs)
68+
call sy#repo#get_diff(sy.buffer, vcs, function('sy#sign#set_signs'))
69+
endif
70+
endfor
71+
endif
6672
endif
6773
endfunction
6874

0 commit comments

Comments
 (0)