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);
<
This commit is contained in:
Jiaobuzuji
2021-09-02 22:27:38 +08:00
committed by GitHub
parent 2c87cae76e
commit 9d5c12e126

View File

@@ -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 "alternative delimiters (if THEY are) as the comment will be better and more
"accurate with multipart delimiters "accurate with multipart delimiters
let switchedDelims = 0 let switchedDelims = 0
if !s:Multipart() && !g:NERDAllowAnyVisualDelims && s:AltMultipart() if !s:Multipart() && g:NERDAllowAnyVisualDelims && s:AltMultipart()
let switchedDelims = 1 let switchedDelims = 1
call nerdcommenter#SwitchToAlternativeDelimiters(0) call nerdcommenter#SwitchToAlternativeDelimiters(0)
endif 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 "switch delimiters (if we can) if the current set isn't multipart
let switchedDelims = 0 let switchedDelims = 0
if !s:Multipart() && s:AltMultipart() && !g:NERDAllowAnyVisualDelims if !s:Multipart() && s:AltMultipart() && g:NERDAllowAnyVisualDelims
let switchedDelims = 1 let switchedDelims = 1
call nerdcommenter#SwitchToAlternativeDelimiters(0) call nerdcommenter#SwitchToAlternativeDelimiters(0)
endif endif