From 310ec8d6a1dcdfad4ae5e75a582cd55ed1b6f9ee Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Mon, 12 Aug 2024 11:22:42 +0200 Subject: [PATCH] QMLJSEditor: Fix calling qmlformat on save Since the "format(...)" function would always create a temporary file first and then let qmlformat work on that it could not find a user supplied .qmlformat.ini in the project folder. To fix this we now create the temporary file next to the actual file. That way the qmlformat tool (and others) can find their config files in the tree hierarchy. Fixes: QTCREATORBUG-29668 Change-Id: I708efbd4bba014bc5743d901725b6fdaa06fefd8 Reviewed-by: David Schulz --- src/plugins/texteditor/formattexteditor.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/texteditor/formattexteditor.cpp b/src/plugins/texteditor/formattexteditor.cpp index 4bd358e3e39..b5496802982 100644 --- a/src/plugins/texteditor/formattexteditor.cpp +++ b/src/plugins/texteditor/formattexteditor.cpp @@ -62,8 +62,9 @@ static FormatOutput format(const FormatInput &input) switch (input.command.processing()) { case Command::FileProcessing: { // Save text to temporary file - Utils::TempFileSaver sourceFile(Utils::TemporaryDirectory::masterDirectoryPath() - + "/qtc_beautifier_XXXXXXXX." + input.filePath.suffix()); + Utils::TempFileSaver sourceFile( + input.filePath.parentDir() + / (input.filePath.fileName() + "_format_XXXXXXXX." + input.filePath.suffix())); sourceFile.setAutoRemove(true); sourceFile.write(input.sourceData.toUtf8()); if (!sourceFile.finalize()) {