Skip to content

Commit 5a3a231

Browse files
committed
Merge pull request #1538 from 'tmatias:toggle_same_ids_check_group'
2 parents 0878992 + ee76970 commit 5a3a231

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

autoload/go/guru.vim

+12-3
Original file line numberDiff line numberDiff line change
@@ -533,24 +533,33 @@ function! s:same_ids_highlight(exit_val, output) abort
533533
endif
534534
endfunction
535535

536+
" ClearSameIds returns 0 when it removes goSameId groups and non-zero if no
537+
" goSameId groups are found.
536538
function! go#guru#ClearSameIds() abort
539+
let l:cleared = 0
540+
537541
let m = getmatches()
538542
for item in m
539543
if item['group'] == 'goSameId'
540544
call matchdelete(item['id'])
545+
let l:cleared = 1
541546
endif
542547
endfor
543548

549+
if !l:cleared
550+
return 1
551+
endif
552+
544553
" remove the autocmds we defined
545554
if exists("#BufWinEnter#<buffer>")
546555
autocmd! BufWinEnter <buffer>
547556
endif
557+
558+
return 0
548559
endfunction
549560

550561
function! go#guru#ToggleSameIds() abort
551-
if len(getmatches()) != 0
552-
call go#guru#ClearSameIds()
553-
else
562+
if go#guru#ClearSameIds() != 0
554563
call go#guru#SameIds()
555564
endif
556565
endfunction

0 commit comments

Comments
 (0)