From 67f8629be3bcbf961c64399db4f9b9496fd6b76f Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 25 Jan 2022 12:29:44 +0800 Subject: [PATCH] - fix: when copy comments, don't auto indent - enhancement: auto add a new line when press enter between '/*' and '*/' --- NEWS.md | 4 ++++ RedPandaIDE/RedPandaIDE.pro | 2 +- RedPandaIDE/qsynedit/SynEdit.cpp | 30 +++++++++++++++++++++++++----- Red_Panda_CPP.pro | 2 +- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index 4d699c45..e8032509 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index ceaf84ed..7a016cfb 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -10,7 +10,7 @@ isEmpty(APP_NAME) { } isEmpty(APP_VERSION) { - APP_VERSION=0.13.3 + APP_VERSION=0.13.4 } isEmpty(PREFIX) { diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 6086f79a..b4eb6884 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -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 += sRightSide; - if (mHighlighter && mOptions.testFlag(eoAutoIndent)) { + if (mHighlighter && mOptions.testFlag(eoAutoIndent) && notInComment) { int indentSpaces = calcIndentSpaces(caretY,Str,true); Str = GetLeftSpacing(indentSpaces,true)+trimLeft(Str); } diff --git a/Red_Panda_CPP.pro b/Red_Panda_CPP.pro index 58f033fb..3e308eba 100644 --- a/Red_Panda_CPP.pro +++ b/Red_Panda_CPP.pro @@ -7,7 +7,7 @@ SUBDIRS += \ APP_NAME = RedPandaCPP -APP_VERSION = 0.13.3 +APP_VERSION = 0.13.4 linux: {