diff --git a/autoload/doge/comment.vim b/autoload/doge/comment.vim index 124816fe..be054f04 100644 --- a/autoload/doge/comment.vim +++ b/autoload/doge/comment.vim @@ -5,17 +5,13 @@ let s:comment_placeholder = doge#helpers#placeholder() " vint: next-line -ProhibitUnusedVariable function! s:jump_forward() abort - let l:wrap = g:doge_comment_jump_wrap == v:true ? 'w' : 'W' - let l:next_pos = search(s:comment_placeholder, 'n' . l:wrap) - - if l:next_pos != 0 - \ && l:next_pos > b:doge_interactive['lnum_comment_end_pos'] - \ && g:doge_comment_jump_wrap == v:true - \ && mode() ==# 's' - " If we have more TODO items below the comment then we'll go back to the - " start position of the comment so we can continue to cycle. This option is - " a 2nd solution besides the 'w' or 'W' being used in the initial search() - " function (called at the top of this function). + let l:next_pos = search(s:comment_placeholder, 'nW') + + if (l:next_pos != 0 && l:next_pos > b:doge_interactive['lnum_comment_end_pos'] || l:next_pos == 0) + \ && g:doge_comment_jump_wrap == v:true + " If we have more TODO items below the comment or we are at the last TODO + " inside the comment, then we'll go backward to the start position of the + " comment so we can continue to cycle. return "\:" . b:doge_interactive['lnum_comment_start_pos'] . "\/" . s:comment_placeholder . "\:silent! noh\gno\" endif @@ -40,17 +36,13 @@ endfunction " vint: next-line -ProhibitUnusedVariable function! s:jump_backward() abort - let l:wrap = g:doge_comment_jump_wrap == v:true ? 'w' : 'W' - let l:prev_pos = search(s:comment_placeholder, 'bn' . l:wrap) - - if l:prev_pos != 0 - \ && l:prev_pos < b:doge_interactive['lnum_comment_start_pos'] - \ && g:doge_comment_jump_wrap == v:true - \ && mode() ==# 's' - " If we have more TODO items above the comment then we'll go forward to the - " end position of the comment so we can continue to cycle. This option is - " a 2nd solution besides the 'w' or 'W' being used in the initial search() - " function (called at the top of this function). + let l:prev_pos = search(s:comment_placeholder, 'bnW') + + if (l:prev_pos != 0 && l:prev_pos < b:doge_interactive['lnum_comment_start_pos'] || l:prev_pos == 0) + \ && g:doge_comment_jump_wrap == v:true + " If we have more TODO items above the comment or we are at the first TODO + " inside the comment, then we'll go forward to the end position of the + " comment so we can continue to cycle. return "\:" . b:doge_interactive['lnum_comment_end_pos'] . "\?" . s:comment_placeholder . "\:silent! noh\gno\" endif