Skip to content

Commit

Permalink
Merge pull request preservim#36 from ches/multipart-with-appended-fix
Browse files Browse the repository at this point in the history
End-of-line comments within a multipart block get uncommented when they shouldn't
  • Loading branch information
scrooloose committed May 6, 2011
2 parents 38630ff + d541c7d commit 4e54565
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions plugin/NERD_commenter.vim
Expand Up @@ -1394,6 +1394,12 @@ endfunction
function s:UncommentLineNormal(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
let lineCommentStatus = s:IsCommentedOuttermost(s:Left(), s:Right(), s:Left({'alt': 1}), s:Right({'alt': 1}), line)

Expand All @@ -1408,34 +1414,23 @@ function s:UncommentLineNormal(line)
"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
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
if indxLeft != -1 && (indxLeft < indxLeftAlt || indxLeftAlt == -1)
let line = s:RemoveDelimiters(s:Left(), '', line)
elseif indxLeftAlt != -1
elseif indxLeftAlt != -1 && g:NERDRemoveAltComs
let line = s:RemoveDelimiters(s:Left({'alt': 1}), '', line)
endif

"remove the outter most right comment delim
if indxRight != -1 && (indxRight < indxRightAlt || indxRightAlt == -1)
let line = s:RemoveDelimiters('', s:Right(), line)
elseif indxRightAlt != -1
elseif indxRightAlt != -1 && g:NERDRemoveAltComs
let line = s:RemoveDelimiters('', s:Right({'alt': 1}), line)
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 indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line)
let indxRightAlt = s:FindDelimiterIndex(s:Right({'alt': 1}), line)
let indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line)

let right = s:Right()
Expand Down

0 comments on commit 4e54565

Please sign in to comment.