diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 1b9dbbc..d9ad0c5 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -2527,7 +2527,9 @@ function! s:ToggleSort() abort return endif + " Save the tag the cursor is currently on let curline = line('.') + let taginfo = s:GetTagInfo(curline, 0) match none @@ -2544,7 +2546,13 @@ function! s:ToggleSort() abort call s:RenderContent() call s:SetStatusLine('current') - execute curline + " If we were on a tag before sorting then jump to it, otherwise restore + " the cursor to the current line + if !empty(taginfo) + execute taginfo.tline + else + execute curline + endif endfunction " Display {{{1