- fix: Autoindent for "{" is not correct.

This commit is contained in:
Roy Qu 2023-07-12 17:13:56 +08:00
parent d629a496ff
commit 2e4de7db07
3 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -102,7 +102,13 @@ namespace QSynedit {
indentSpaces = editor->leftSpaces(editor->document()->getLine(matchingIndents.line));
} else if (firstToken=="{") {
IndentInfo matchingIndents = rangeAfterFirstToken.getLastIndent();
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();

View File

@ -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);