From 0faea6ac693f3d038b37133164a9e4283f13ab05 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 20 Feb 2024 12:51:01 +0800 Subject: [PATCH] - Enhancement: Don't auto-indent in raw string. --- NEWS.md | 1 + libs/qsynedit/qsynedit/formatter/cppformatter.cpp | 2 ++ libs/qsynedit/qsynedit/syntaxer/cpp.h | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 5e3b35d1..4c674ec0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -44,6 +44,7 @@ Red Panda C++ Version 2.26 - Fix: Force to use debug server when debugging with lldb-mi to fix input/output on Windows. - Fix: Can't goto definition/declaration into files that not saved. - Fix: Expression that starts with full scoped variables might be treated as var definition. + - Enhancement: Don't auto-indent in raw string. Red Panda C++ Version 2.25 diff --git a/libs/qsynedit/qsynedit/formatter/cppformatter.cpp b/libs/qsynedit/qsynedit/formatter/cppformatter.cpp index 41fa8e2a..3ad02e2e 100644 --- a/libs/qsynedit/qsynedit/formatter/cppformatter.cpp +++ b/libs/qsynedit/qsynedit/formatter/cppformatter.cpp @@ -40,6 +40,8 @@ namespace QSynedit { if (editor->syntaxer()->language() != ProgrammingLanguage::CPP) return indentSpaces; SyntaxState rangePreceeding = editor->document()->getSyntaxState(startLine-1); + if (rangePreceeding.state == CppSyntaxer::RangeState::rsRawStringNotEscaping) + return 0; if (addIndent) { // QString trimmedS = s.trimmed(); QString trimmedLineText = lineText.trimmed(); diff --git a/libs/qsynedit/qsynedit/syntaxer/cpp.h b/libs/qsynedit/qsynedit/syntaxer/cpp.h index 48430541..2c7509ad 100644 --- a/libs/qsynedit/qsynedit/syntaxer/cpp.h +++ b/libs/qsynedit/qsynedit/syntaxer/cpp.h @@ -23,6 +23,7 @@ namespace QSynedit { class CppSyntaxer: public Syntaxer { +public: enum class TokenId { Comment, Directive, @@ -53,7 +54,6 @@ class CppSyntaxer: public Syntaxer rsDefineIdentifier, rsDefineRemaining, }; -public: explicit CppSyntaxer(); CppSyntaxer(const CppSyntaxer&)=delete; CppSyntaxer operator=(const CppSyntaxer&)=delete;