Skip to content

Commit

Permalink
Fix hasmapto() condition not working as intended
Browse files Browse the repository at this point in the history
The RHS of the CommentaryUndo mappings causes the hasmapto() below to
always return TRUE, causing vim-commentary to not create any mappings
when "gc" is mapped even if there are no user custom mappings.
  • Loading branch information
zeertzjq authored and tpope committed Apr 8, 2024
1 parent f67e3e6 commit c4b8f52
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugin/commentary.vim
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ nnoremap <expr> <Plug>Commentary <SID>go()
nnoremap <expr> <Plug>CommentaryLine <SID>go() . '_' nnoremap <expr> <Plug>CommentaryLine <SID>go() . '_'
onoremap <silent> <Plug>Commentary :<C-U>call <SID>textobject(get(v:, 'operator', '') ==# 'c')<CR> onoremap <silent> <Plug>Commentary :<C-U>call <SID>textobject(get(v:, 'operator', '') ==# 'c')<CR>
nnoremap <silent> <Plug>ChangeCommentary c:<C-U>call <SID>textobject(1)<CR> nnoremap <silent> <Plug>ChangeCommentary c:<C-U>call <SID>textobject(1)<CR>
nmap <silent> <Plug>CommentaryUndo :echoerr "Change your <Plug>CommentaryUndo map to <Plug>Commentary<Plug>Commentary"<CR>
if !hasmapto('<Plug>Commentary') || maparg('gc','n') ==# '' if !hasmapto('<Plug>Commentary') || maparg('gc','n') ==# ''
xmap gc <Plug>Commentary xmap gc <Plug>Commentary
Expand All @@ -118,4 +117,6 @@ if !hasmapto('<Plug>Commentary') || maparg('gc','n') ==# ''
nmap gcu <Plug>Commentary<Plug>Commentary nmap gcu <Plug>Commentary<Plug>Commentary
endif endif


nmap <silent> <Plug>CommentaryUndo :echoerr "Change your <Plug>CommentaryUndo map to <Plug>Commentary<Plug>Commentary"<CR>
" vim:set et sw=2: " vim:set et sw=2:

0 comments on commit c4b8f52

Please sign in to comment.