From 9d5c12e126a72f0204688b81ad9d022ff6d7f11a Mon Sep 17 00:00:00 2001 From: Jiaobuzuji Date: Thu, 2 Sep 2021 22:27:38 +0800 Subject: [PATCH] fix 'g:NERDAllowAnyVisualDelims' action fix 'g:NERDAllowAnyVisualDelims' action. *'NERDAllowAnyVisualDelims'* Values: 0 or 1. Default: 1. If set to 1 then, when doing a visual or visual-block comment (but not a visual-line comment), the script will choose the right delimiters to use for the comment. This means either using the current delimiters if they are multipart or using the alternative delimiters if THEY are multipart. For example if we are editing the following java code: > float foo = 1221; float bar = 324; System.out.println(foo * bar); < If we are using // comments and select the "foo" and "bar" in visual-block mode, as shown left below (where '|'s are used to represent the visual-block boundary), and comment it then the script will use the alternative delimiters as shown on the right: > float |foo| = 1221; float /*foo*/ = 1221; float |bar| = 324; float /*bar*/ = 324; System.out.println(foo * bar); System.out.println(foo * bar); < --- autoload/nerdcommenter.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/nerdcommenter.vim b/autoload/nerdcommenter.vim index c005fa8..ac7c7cb 100644 --- a/autoload/nerdcommenter.vim +++ b/autoload/nerdcommenter.vim @@ -651,7 +651,7 @@ function! s:CommentBlock(top, bottom, lSide, rSide, forceNested) abort "alternative delimiters (if THEY are) as the comment will be better and more "accurate with multipart delimiters let switchedDelims = 0 - if !s:Multipart() && !g:NERDAllowAnyVisualDelims && s:AltMultipart() + if !s:Multipart() && g:NERDAllowAnyVisualDelims && s:AltMultipart() let switchedDelims = 1 call nerdcommenter#SwitchToAlternativeDelimiters(0) endif @@ -1068,7 +1068,7 @@ function! s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested) a "switch delimiters (if we can) if the current set isn't multipart let switchedDelims = 0 - if !s:Multipart() && s:AltMultipart() && !g:NERDAllowAnyVisualDelims + if !s:Multipart() && s:AltMultipart() && g:NERDAllowAnyVisualDelims let switchedDelims = 1 call nerdcommenter#SwitchToAlternativeDelimiters(0) endif