diff --git a/NEWS.md b/NEWS.md index 5e55592f..8ecab2aa 100644 --- a/NEWS.md +++ b/NEWS.md @@ -42,7 +42,8 @@ Red Panda C++ Version 2.23 - enhancement: When problem case's expected output is not too large (<= 5000 line), highlight text in the first different line in the expected output. - enhancement: Highlight text in the first different line using the error color. - enhancement: Add the option "redirect stderr to the Tools output panel" in the options dialog -> executor -> problem set page. - + - fix: Can't correctly uncomment multiple "//" comment lines that doesn't have spaces at linestarts. + - fix: Autoindent for "{" is not correct. Red Panda C++ Version 2.22 diff --git a/libs/qsynedit/qsynedit/formatter/cppformatter.cpp b/libs/qsynedit/qsynedit/formatter/cppformatter.cpp index a2e73211..4159d121 100644 --- a/libs/qsynedit/qsynedit/formatter/cppformatter.cpp +++ b/libs/qsynedit/qsynedit/formatter/cppformatter.cpp @@ -102,7 +102,13 @@ namespace QSynedit { indentSpaces = editor->leftSpaces(editor->document()->getLine(matchingIndents.line)); } else if (firstToken=="{") { IndentInfo matchingIndents = rangeAfterFirstToken.getLastIndent(); - indentSpaces = editor->leftSpaces(editor->document()->getLine(matchingIndents.line)); + if (matchingIndents.line!=line-1) { + indentSpaces = editor->leftSpaces(editor->document()->getLine(matchingIndents.line)); + } else if (rangeAfterFirstToken.indents.count()>=2){ + IndentInfo info = rangeAfterFirstToken.indents[rangeAfterFirstToken.indents.count()-2]; + indentSpaces = editor->leftSpaces(editor->document()->getLine(info.line))+editor->tabWidth(); + } else + indentSpaces = 0; } else if (rangePreceeding.getLastIndentType()!=IndentType::None) { IndentInfo matchingIndents = rangePreceeding.getLastIndent(); indentSpaces = editor->leftSpaces(editor->document()->getLine(matchingIndents.line))+editor->tabWidth(); diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index eff3966d..d4bde49b 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -1651,7 +1651,7 @@ void QSynEdit::doUncomment() continue; // Find // after blanks only int j = 0; - while ((j+1 < s.length()) && (s[j] == '\n' || s[j] == '\t')) + while ((j+1 < s.length()) && (s[j] == ' ' || s[j] == '\t')) j++; s.remove(j,symbolLen); mDocument->putLine(i,s);