CppEditor: Do not remove newlines in "apply signature changes"

Task-number: QTCREATORBUG-31293
Change-Id: I7e145e57a86c5bcb90c8c41fd9794e3c94255b49
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2024-10-28 17:28:50 +01:00
parent 00f4da3950
commit 768494b611

View File

@@ -477,10 +477,14 @@ static IndicesList unmatchedIndices(const IndicesList &indices)
static QString ensureCorrectParameterSpacing(const QString &text, bool isFirstParam) static QString ensureCorrectParameterSpacing(const QString &text, bool isFirstParam)
{ {
if (isFirstParam) { // drop leading spaces if (isFirstParam) { // drop leading spaces
int newlineCount = 0;
int firstNonSpace = 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; ++firstNonSpace;
return text.mid(firstNonSpace); }
return QString(newlineCount, QChar::ParagraphSeparator) + text.mid(firstNonSpace);
} else { // ensure one leading space } else { // ensure one leading space
if (text.isEmpty() || !text.at(0).isSpace()) if (text.isEmpty() || !text.at(0).isSpace())
return QLatin1Char(' ') + text; return QLatin1Char(' ') + text;