Skip to content

Commit

Permalink
Merge pull request #12 from akiomik/hotfix/support-other-buffers
Browse files Browse the repository at this point in the history
fixed window variables initialization bug
  • Loading branch information
akiomik committed Mar 12, 2013
2 parents e348af6 + 427dc80 commit bea01e1
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions autoload/gitgutter.vim
Expand Up @@ -35,12 +35,6 @@ function! s:init()
sign define add text=+ texthl=gitGutterAdd
sign define delete_top text=^ texthl=gitGutterDelete
sign define delete_bottom text=_ texthl=gitGutterDelete

" init window variables
if !exists('w:marked_lines')
let w:marked_lines = {}
let w:prev_marked_lines = {}
endif
endfunction


Expand All @@ -57,7 +51,7 @@ function! s:mark(name, begin, end)

" set
exe ":sign place " . i . " line=" . i . " name=" . a:name . " file=" . expand("%:p")
let w:marked_lines[i] = a:name
let b:marked_lines[i] = a:name

let i += 1
endwhile
Expand All @@ -66,9 +60,9 @@ endfunction

" reset mark
function! s:reset_mark(i)
if has_key(w:prev_marked_lines, a:i)
if has_key(b:prev_marked_lines, a:i)
exe ":sign unplace " . a:i . " file=" . expand("%:p")
call remove(w:prev_marked_lines, a:i)
call remove(b:prev_marked_lines, a:i)
endif
endfunction

Expand Down Expand Up @@ -112,7 +106,6 @@ endfunction
function! s:get_diff(current)
let filename = expand("%")
let prefix = system('git rev-parse --show-prefix')[ :-2]
echo 'git show HEAD:' . prefix . filename . ' | diff - ' . a:current

let diff = system('git show HEAD:' . prefix . filename . ' | diff - ' . a:current)
return split(diff, '\n')
Expand All @@ -137,8 +130,11 @@ function! gitgutter#git_gutter()
let diff = s:get_diff(current)

" init marked lines
let w:prev_marked_lines = w:marked_lines
let w:marked_lines = {}
if !exists('b:marked_lines')
let b:marked_lines = {}
endif
let b:prev_marked_lines = b:marked_lines
let b:marked_lines = {}

" parse diff
for line in diff
Expand Down Expand Up @@ -168,7 +164,7 @@ function! gitgutter#git_gutter()
endif
endfor

for i in keys(w:prev_marked_lines)
for i in keys(b:prev_marked_lines)
call s:reset_mark(i)
endfor
endfunction
Expand Down

0 comments on commit bea01e1

Please sign in to comment.