[ENHENCEMENT] Block comment work with line characters more than 1024.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1048 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2013-05-21 18:13:34 +00:00
parent 71234725a1
commit 0bd5bfa635

View File

@ -3429,8 +3429,6 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
generic_string comment(commentLineSybol);
comment += TEXT(" ");
const int linebufferSize = 1024;
TCHAR linebuf[linebufferSize];
size_t comment_length = comment.length();
size_t selectionStart = _pEditView->execute(SCI_GETSELECTIONSTART);
size_t selectionEnd = _pEditView->execute(SCI_GETSELECTIONEND);
@ -3453,17 +3451,20 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
int lineStart = _pEditView->execute(SCI_POSITIONFROMLINE, i);
int lineIndent = lineStart;
int lineEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, i);
if ((lineEnd - lineIndent) >= linebufferSize) // Avoid buffer size problems
continue;
size_t linebufferSize = lineEnd - lineStart + 2;
TCHAR* linebuf = new TCHAR[linebufferSize];
lineIndent = _pEditView->execute(SCI_GETLINEINDENTPOSITION, i);
_pEditView->getGenericText(linebuf, linebufferSize, lineIndent, lineEnd);
generic_string linebufStr = linebuf;
delete [] linebuf;
// empty lines are not commented
if (lstrlen(linebuf) < 1)
if (linebufStr.length() < 1)
continue;
if (currCommentMode != cm_comment)
{
//--FLS: In order to do get case insensitive comparison use strnicmp() instead case-sensitive comparison.