diff options
author | Semih Yavuz <[email protected]> | 2024-11-08 16:57:22 +0100 |
---|---|---|
committer | Semih Yavuz <[email protected]> | 2024-12-05 23:24:30 +0100 |
commit | 3bb4962254498504c135ca0243c0be5bdf6defad (patch) | |
tree | 2a721b800dea110cfb0f564b0ddff882a7ad3493 /tools/qmlformat/qmlformat.cpp | |
parent | 9f1fca90e7b760f54e5fb5689e662defb669c64b (diff) |
qmlformat: use indenting line writer if column break is in use
Task-number: QTBUG-113590
Change-Id: I24e1d8df81736b63d8b2eb25aa8625b9e22b211a
Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'tools/qmlformat/qmlformat.cpp')
-rw-r--r-- | tools/qmlformat/qmlformat.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/qmlformat/qmlformat.cpp b/tools/qmlformat/qmlformat.cpp index 82cca36ab1..e960072322 100644 --- a/tools/qmlformat/qmlformat.cpp +++ b/tools/qmlformat/qmlformat.cpp @@ -14,6 +14,7 @@ #include <QtQmlDom/private/qqmldomexternalitems_p.h> #include <QtQmlDom/private/qqmldomtop_p.h> #include <QtQmlDom/private/qqmldomoutwriter_p.h> +#include <QtQmlDom/private/qqmldomlinewriterfactory_p.h> #if QT_CONFIG(commandlineparser) # include <QCommandLineParser> @@ -92,9 +93,8 @@ static bool parseFile(const QString &filename, const QQmlFormatOptions &options) auto lwOptions = options.optionsForCode(code); WriteOutChecks checks = WriteOutCheck::Default; //Disable writeOutChecks for some usecases - if (options.forceEnabled() || - code.size() > 32000 || - fileItem.internalKind() == DomType::JsFile) { + if (options.forceEnabled() || options.isMaxColumnWidthSet() || code.size() > 32000 + || fileItem.internalKind() == DomType::JsFile) { checks = WriteOutCheck::None; } @@ -108,8 +108,9 @@ static bool parseFile(const QString &filename, const QQmlFormatOptions &options) } else { QFile out; if (out.open(stdout, QIODevice::WriteOnly)) { - LineWriter lw([&out](QStringView s) { out.write(s.toUtf8()); }, filename, lwOptions); - OutWriter ow(lw); + auto lw = createLineWriter([&out](QStringView s) { out.write(s.toUtf8()); }, filename, + lwOptions); + OutWriter ow(*lw); res = fileItem.writeOutForFile(ow, checks); ow.flush(); } else { |