Closed SnowMB closed 2 years ago
Thanks for the bug report. I will try to get my hands on a Windows machine and will keep you posted.
I just tested with 6.4.0 and same results.
Hi @SnowMB.
I identified the problem. However, during my tests, a noticed another issue.
When running C:\Qt\6.4.0\msvc2019_64\bin\qmlformat.exe --inplace main.qml
(outside of VS Code, note the --inplace
argument) it also created a file named main.qml~
which wasn't automatically deleted.
Did you notice something similar with 6.4.0 or is it a problem on my side only?
Asking to know if I should implement a workaround inside the qml-format
extension or not.
Hey @Delgan,
thank you for your time in investigating this issue. 👍
I also get the .qml~
files when running with the --inplace
argument. If I understood correctly your extension does not rely on using --inplace
so this would not be something you need to fix here?
Personally I just ignore them with git so not a problem for me either.
Thanks for the test, @SnowMB. :)
Regarding the .qml~
files created, I actually opened a ticket on Qt bug tracker: QTBUG-107685.
It should be fixed in one of their upcoming releases.
You're right that this extension originally did not use --inplace
. However, I needed to modify the implementation to fix the double new lines bug!
Actually, I learned that "\n"
is automatically converted in "\r\n"
on Windows while writing to a non-binary stream. So, when qmlformat
was outputing "\r\n"
due to NewlineType=windows
, the output I received from the execute process contained "\r\r\n"
.
To solve the problem, the stdout
would have to be opened in binary mode, but this is not necessarily very simple or portable.
Therefore, I decided to use --inplace
internally so that qmlformat
can format the file without going through stdout
.
I just release v1.0.4
, it should fix your issue. :+1:
@Delgan thank you so much!
I try to use this extension on Windows with qmlformat.exe from qt 6.3.1.
When I manually call the formatter on the command line i get the expected result:
.qmlformat.ini
However when using the extension in vscode I get a different result:
settings.json
: