mirror of
https://github.com/preservim/nerdcommenter.git
synced 2025-11-11 19:23:47 -05:00
Merge pull request #36 from ches/multipart-with-appended-fix
End-of-line comments within a multipart block get uncommented when they shouldn't
This commit is contained in:
@@ -1394,6 +1394,12 @@ endfunction
|
|||||||
function s:UncommentLineNormal(line)
|
function s:UncommentLineNormal(line)
|
||||||
let line = a:line
|
let line = a:line
|
||||||
|
|
||||||
|
"get the positions of all delim types on the line
|
||||||
|
let indxLeft = s:FindDelimiterIndex(s:Left(), line)
|
||||||
|
let indxLeftAlt = s:FindDelimiterIndex(s:Left({'alt': 1}), line)
|
||||||
|
let indxRight = s:FindDelimiterIndex(s:Right(), line)
|
||||||
|
let indxRightAlt = s:FindDelimiterIndex(s:Right({'alt': 1}), line)
|
||||||
|
|
||||||
"get the comment status on the line so we know how it is commented
|
"get the comment status on the line so we know how it is commented
|
||||||
let lineCommentStatus = s:IsCommentedOuttermost(s:Left(), s:Right(), s:Left({'alt': 1}), s:Right({'alt': 1}), line)
|
let lineCommentStatus = s:IsCommentedOuttermost(s:Left(), s:Right(), s:Left({'alt': 1}), s:Right({'alt': 1}), line)
|
||||||
|
|
||||||
@@ -1408,34 +1414,23 @@ function s:UncommentLineNormal(line)
|
|||||||
"it is not properly commented with any delims so we check if it has
|
"it is not properly commented with any delims so we check if it has
|
||||||
"any random left or right delims on it and remove the outtermost ones
|
"any random left or right delims on it and remove the outtermost ones
|
||||||
else
|
else
|
||||||
"get the positions of all delim types on the line
|
|
||||||
let indxLeft = s:FindDelimiterIndex(s:Left(), line)
|
|
||||||
let indxLeftAlt = s:FindDelimiterIndex(s:Left({'alt': 1}), line)
|
|
||||||
let indxRight = s:FindDelimiterIndex(s:Right(), line)
|
|
||||||
let indxRightAlt = s:FindDelimiterIndex(s:Right({'alt': 1}), line)
|
|
||||||
|
|
||||||
"remove the outter most left comment delim
|
"remove the outter most left comment delim
|
||||||
if indxLeft != -1 && (indxLeft < indxLeftAlt || indxLeftAlt == -1)
|
if indxLeft != -1 && (indxLeft < indxLeftAlt || indxLeftAlt == -1)
|
||||||
let line = s:RemoveDelimiters(s:Left(), '', line)
|
let line = s:RemoveDelimiters(s:Left(), '', line)
|
||||||
elseif indxLeftAlt != -1
|
elseif indxLeftAlt != -1 && g:NERDRemoveAltComs
|
||||||
let line = s:RemoveDelimiters(s:Left({'alt': 1}), '', line)
|
let line = s:RemoveDelimiters(s:Left({'alt': 1}), '', line)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"remove the outter most right comment delim
|
"remove the outter most right comment delim
|
||||||
if indxRight != -1 && (indxRight < indxRightAlt || indxRightAlt == -1)
|
if indxRight != -1 && (indxRight < indxRightAlt || indxRightAlt == -1)
|
||||||
let line = s:RemoveDelimiters('', s:Right(), line)
|
let line = s:RemoveDelimiters('', s:Right(), line)
|
||||||
elseif indxRightAlt != -1
|
elseif indxRightAlt != -1 && g:NERDRemoveAltComs
|
||||||
let line = s:RemoveDelimiters('', s:Right({'alt': 1}), line)
|
let line = s:RemoveDelimiters('', s:Right({'alt': 1}), line)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
let indxLeft = s:FindDelimiterIndex(s:Left(), line)
|
|
||||||
let indxLeftAlt = s:FindDelimiterIndex(s:Left({'alt': 1}), line)
|
|
||||||
let indxLeftPlace = s:FindDelimiterIndex(g:NERDLPlace, line)
|
let indxLeftPlace = s:FindDelimiterIndex(g:NERDLPlace, line)
|
||||||
|
|
||||||
let indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line)
|
|
||||||
let indxRightAlt = s:FindDelimiterIndex(s:Right({'alt': 1}), line)
|
|
||||||
let indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line)
|
let indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line)
|
||||||
|
|
||||||
let right = s:Right()
|
let right = s:Right()
|
||||||
|
|||||||
Reference in New Issue
Block a user