Use buffer numbers instead of buffer names.

Also don't pass buffer number to functions when they can look it up
themselves.

Using buffer numbers also eliminates any ambiguity which might arise
from symbolic links, where you have potentially two names for a file.

Thanks to @Z1MM32M4N for work on this (see #209).
This commit is contained in:
Andy Stewart
2014-11-14 12:55:40 +01:00
parent ce4e3d7c9a
commit dfe985a1a6
4 changed files with 74 additions and 66 deletions

View File

@@ -53,7 +53,7 @@ call gitgutter#highlight#define_signs()
" Primary functions {{{
command GitGutterAll call gitgutter#all()
command GitGutter call gitgutter#process_buffer(gitgutter#utility#current_file(), 0)
command GitGutter call gitgutter#process_buffer(bufnr(''), 0)
command GitGutterDisable call gitgutter#disable()
command GitGutterEnable call gitgutter#enable()
@@ -157,7 +157,7 @@ augroup gitgutter
autocmd!
if g:gitgutter_realtime
autocmd CursorHold,CursorHoldI * call gitgutter#process_buffer(gitgutter#utility#current_file(), 1)
autocmd CursorHold,CursorHoldI * call gitgutter#process_buffer(bufnr(''), 1)
endif
if g:gitgutter_eager
@@ -165,7 +165,7 @@ augroup gitgutter
\ if gettabvar(tabpagenr(), 'gitgutter_didtabenter') |
\ call settabvar(tabpagenr(), 'gitgutter_didtabenter', 0) |
\ else |
\ call gitgutter#process_buffer(gitgutter#utility#current_file(), 0) |
\ call gitgutter#process_buffer(bufnr(''), 0) |
\ endif
autocmd TabEnter *
\ call settabvar(tabpagenr(), 'gitgutter_didtabenter', 1) |
@@ -174,7 +174,7 @@ augroup gitgutter
autocmd FocusGained * call gitgutter#all()
endif
else
autocmd BufRead,BufWritePost,FileChangedShellPost * call gitgutter#process_buffer(gitgutter#utility#current_file(), 0)
autocmd BufRead,BufWritePost,FileChangedShellPost * call gitgutter#process_buffer(bufnr(''), 0)
endif
autocmd ColorScheme * call gitgutter#highlight#define_sign_column_highlight() | call gitgutter#highlight#define_highlights()