From 94884246d445fb3e702ac8c4d4bb432768e61b61 Mon Sep 17 00:00:00 2001 From: Alexander Akulich Date: Sat, 25 Aug 2018 18:23:04 +0300 Subject: QCommandLineParser: Ensure that an option text ends with a newline Before this change we inserted newline only if an option has a description and ended up with an arbitrary long line with all options. [ChangeLog][QtCore][QCommandLineParser] Fixed a bug that caused the help output to show two options or more in the same line if the options didn't have a description. Task-number: QTBUG-70174 Change-Id: Id54b9ae13ee596869e4dc14e09301aea19eed2f8 Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/corelib/tools/qcommandlineparser.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp index 4c55880915..279d6565da 100644 --- a/src/corelib/tools/qcommandlineparser.cpp +++ b/src/corelib/tools/qcommandlineparser.cpp @@ -1049,7 +1049,11 @@ QString QCommandLineParser::helpText() const static QString wrapText(const QString &names, int longestOptionNameString, const QString &description) { const QLatin1Char nl('\n'); - QString text = QLatin1String(" ") + names.leftJustified(longestOptionNameString) + QLatin1Char(' '); + const QLatin1String indentation(" "); + if (description.isEmpty()) + return indentation + names + nl; + + QString text = indentation + names.leftJustified(longestOptionNameString) + QLatin1Char(' '); const int indent = text.length(); int lineStart = 0; int lastBreakable = -1; -- cgit v1.2.3