From 768494b6112d0fd781f152effe37f6eda568b9cb Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 28 Oct 2024 17:28:50 +0100 Subject: [PATCH] CppEditor: Do not remove newlines in "apply signature changes" Task-number: QTCREATORBUG-31293 Change-Id: I7e145e57a86c5bcb90c8c41fd9794e3c94255b49 Reviewed-by: David Schulz --- src/plugins/cppeditor/cppfunctiondecldeflink.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp index e6722206df2..c6abbcc36a5 100644 --- a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp +++ b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp @@ -477,10 +477,14 @@ static IndicesList unmatchedIndices(const IndicesList &indices) static QString ensureCorrectParameterSpacing(const QString &text, bool isFirstParam) { if (isFirstParam) { // drop leading spaces + int newlineCount = 0; int firstNonSpace = 0; - while (firstNonSpace + 1 < text.size() && text.at(firstNonSpace).isSpace()) + while (firstNonSpace + 1 < text.size() && text.at(firstNonSpace).isSpace()) { + if (text.at(firstNonSpace) == QChar::ParagraphSeparator) + ++newlineCount; ++firstNonSpace; - return text.mid(firstNonSpace); + } + return QString(newlineCount, QChar::ParagraphSeparator) + text.mid(firstNonSpace); } else { // ensure one leading space if (text.isEmpty() || !text.at(0).isSpace()) return QLatin1Char(' ') + text;