Skip to content

Commit

Permalink
Merge pull request #998 from bhcleek/sameid-autocmd
Browse files Browse the repository at this point in the history
Re-evaluate sameids after buffer is re-entered
  • Loading branch information
fatih authored Aug 9, 2016
2 parents a0edd32 + 7d14337 commit 973724f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion autoload/go/guru.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
" guru.vim -- Vim integration for the Go guru.


func! s:RunGuru(mode, format, selected, needs_scope) range abort
"return with a warning if the binary doesn't exist
let bin_path = go#path#CheckBinPath("guru")
Expand Down Expand Up @@ -364,6 +363,12 @@ function! go#guru#SameIds(selected)
let pos = split(item, ':')
call matchaddpos('goSameId', [[str2nr(pos[-2]), str2nr(pos[-1]), str2nr(poslen)]])
endfor

if get(g:, "go_auto_sameids", 0)
" re-apply SameIds at the current cursor position at the time the buffer
" is redisplayed: e.g. :edit, :GoRename, etc.
autocmd BufWinEnter <buffer> nested call go#guru#SameIds(-1)
endif
endfunction

function! go#guru#ClearSameIds()
Expand All @@ -373,6 +378,11 @@ function! go#guru#ClearSameIds()
call matchdelete(item['id'])
endif
endfor

" remove the autocmds we defined
if exists("#BufWinEnter<buffer>")
autocmd! BufWinEnter <buffer>
endif
endfunction

function! go#guru#ToggleSameIds(selected)
Expand Down

0 comments on commit 973724f

Please sign in to comment.