- fix: when copy comments, don't auto indent

- enhancement: auto add a new line when press enter between '/*' and '*/'
This commit is contained in:
Roy Qu 2022-01-25 12:29:44 +08:00
parent db9f0f0219
commit 67f8629be3
4 changed files with 31 additions and 7 deletions

View File

@ -1,3 +1,7 @@
Red Panda C++ Version 0.13.4
- fix: when copy comments, don't auto indent
- enhancement: auto add a new line when press enter between '/*' and '*/'
Red Panda C++ Version 0.13.3
- enhancement: restore editor position after rename symbol
- enhancement: restore editor position after reformat code

View File

@ -10,7 +10,7 @@ isEmpty(APP_NAME) {
}
isEmpty(APP_VERSION) {
APP_VERSION=0.13.3
APP_VERSION=0.13.4
}
isEmpty(PREFIX) {

View File

@ -2256,6 +2256,18 @@ void SynEdit::insertLine(bool moveCaret)
mUndoList->AddChange(SynChangeReason::crLineBreak, caretXY(), caretXY(), rightLineText,
SynSelectionMode::smNormal);
//insert new line in middle of "/*" and "*/"
if (!notInComment &&
( leftLineText.endsWith("/*") && rightLineText.startsWith("*/")
)) {
indentSpaces = calcIndentSpaces(mCaretY+1, "" , mOptions.testFlag(eoAutoIndent)) + mTabWidth;
indentSpacesForRightLineText = GetLeftSpacing(indentSpaces,true);
mLines->insert(mCaretY, indentSpacesForRightLineText);
nLinesInserted++;
mUndoList->AddChange(SynChangeReason::crLineBreak, caretXY(), caretXY(), "",
SynSelectionMode::smNormal);
}
//insert new line in middle of "{" and "}"
if (notInComment &&
( leftLineText.endsWith('{') && rightLineText.startsWith('}')
@ -5120,6 +5132,10 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
rescanRange(caretY);
// step2: insert remaining lines of Value
while (P < Value.length()) {
bool notInComment = !mHighlighter->isLastLineCommentNotFinished(
mHighlighter->getRangeState().state)
&& !mHighlighter->isLastLineStringNotFinished(
mHighlighter->getRangeState().state);
if (Value[P] == '\r')
P++;
if (Value[P] == '\n')
@ -5129,15 +5145,19 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
Start = P;
P = GetEOL(Value,Start);
if (P == Start) {
if (P<Value.length())
Str = GetLeftSpacing(calcIndentSpaces(caretY,"",true),true);
else
Str = sRightSide;
if (P<Value.length()) {
if (mHighlighter && mOptions.testFlag(eoAutoIndent) && notInComment) {
Str = GetLeftSpacing(calcIndentSpaces(caretY,"",true),true);
} else {
Str = "";
}
} else
Str = sRightSide;
} else {
Str = Value.mid(Start, P-Start);
if (P>=Value.length())
Str += sRightSide;
if (mHighlighter && mOptions.testFlag(eoAutoIndent)) {
if (mHighlighter && mOptions.testFlag(eoAutoIndent) && notInComment) {
int indentSpaces = calcIndentSpaces(caretY,Str,true);
Str = GetLeftSpacing(indentSpaces,true)+trimLeft(Str);
}

View File

@ -7,7 +7,7 @@ SUBDIRS += \
APP_NAME = RedPandaCPP
APP_VERSION = 0.13.3
APP_VERSION = 0.13.4
linux: {