From 1dbc0972ab26f0fbaf07586b4e5eaebde2d72d5c Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 11 Nov 2022 09:00:06 +0800 Subject: [PATCH] - fix: Escape suquences like \uxxxx and \Uxxxxxxxx in strings are not correctly highlighted. --- NEWS.md | 1 + RedPandaIDE/editor.cpp | 2 -- libs/qsynedit/qsynedit/highlighter/cpp.cpp | 12 ++++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8f64fcde..794dfa38 100644 --- a/NEWS.md +++ b/NEWS.md @@ -19,6 +19,7 @@ Red Panda C++ Version 2.4 - fix: Layout for project options dialog's general page is not correct. - fix: modifitions in the project options dialogs's dll host page is not correctly saved. - enhancement: In the project options dialog, autoset the default folder in the openning dialog when choosing file/directory paths. + - fix: Escape suquences like \uxxxx and \Uxxxxxxxx in strings are not correctly highlighted. Red Panda C++ Version 2.3 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 9c75ca40..d0bb8b8a 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -783,9 +783,7 @@ void Editor::keyPressEvent(QKeyEvent *event) return; } } - qDebug()<<"lalalala"; lastWord = getPreviousWordAtPositionForCompleteFunctionDefinition(caretXY()); - qDebug()<findScopeStatement(mFilename,caretY()); while(currentScope && currentScope->kind==StatementKind::skBlock) { diff --git a/libs/qsynedit/qsynedit/highlighter/cpp.cpp b/libs/qsynedit/qsynedit/highlighter/cpp.cpp index 044ed36b..8605bd02 100644 --- a/libs/qsynedit/qsynedit/highlighter/cpp.cpp +++ b/libs/qsynedit/qsynedit/highlighter/cpp.cpp @@ -1174,7 +1174,11 @@ void CppHighlighter::stringEscapeSeqProc() case 'u': mRun+=1; for (int i=0;i<4;i++) { - if (mRun>=mLineSize || mLine[mRun]<'0' || mLine[mRun]>'7') { + if (mRun>=mLineSize || !( + (mLine[mRun]>='0' && mLine[mRun]<='9') + || (mLine[mRun]>='a' && mLine[mRun]<='f') + || (mLine[mRun]>='A' && mLine[mRun]<='F') + )) { mTokenId = TokenId::Unknown; return; } @@ -1184,7 +1188,11 @@ void CppHighlighter::stringEscapeSeqProc() case 'U': mRun+=1; for (int i=0;i<8;i++) { - if (mRun>=mLineSize || mLine[mRun]<'0' || mLine[mRun]>'7') { + if (mRun>=mLineSize || !( + (mLine[mRun]>='0' && mLine[mRun]<='9') + || (mLine[mRun]>='a' && mLine[mRun]<='f') + || (mLine[mRun]>='A' && mLine[mRun]<='F') + )) { mTokenId = TokenId::Unknown; return; }