Closed samishchandra closed 4 years ago
Used the following config as workaround.
"uncrustify.useReplaceOption": true,
This extension sends the file content through stdin
to uncrustify, that's why it doesn't sue the file name by default.
And indeed, using "uncrustify.useReplaceOption": true
fixes it by forcing VSCode to save the file, ans then formatting the file directly.
But setting this option doesn't work with option "formatOnSave" in VScode. ?
Setting useReplaceOption
to true
and formatOnSave
to true
still works for me
It shows me this process dialog and never completes.
But when I make useReplaceOption = false
.. it works.. but doesn't take filename into account though.
Does it also do this on files outside of Dropbox ?
Nevermind, Dropbox syncs files on disk, it's not a remote filesystem.
What are the contents of the test file ?
If it helps with debugging.. clicking the "Cancel" button above actually outputs the extensions log and formats the file.. which is weird..
I think the problem comes from the fact that when formatting, it will try to save the file, then saving will cause formatting, which will cause saving, etc.
During formatting, without using useReplaceOption
, I have to use the file content from VSCode without reading the file on the disk, and I send it to Uncrustify on stdin. There is no way to specify the filename to Uncrustify when sending data through stdin, as far as I know.
Oh interesting, is there a way to write contents of the file to temporary file with same filename.. and get results of the formatter ? Probably that way we avoid the loop.
This could be possible, although not very good for performance
Can we support it with a option to control may be. Thanks.
This should be possible using uncrustify.useTempFile
now. Additionally, maybe it will also work with uncrustify.useReplaceOption
, there was indeed a bug with it that should be fixed now
Thanks a lot Laurent for fixing the issue in quick time. Really appreciate it.
Is this available on the latest? or do I have to do something ?
It should be available on the latest version
Oh, I think the version it is compatible is ^1.43.0
.. but i am currently on vscode 1.42.0
.. is it a hard restriction or can we lower that version ?
Btw.. i tested the flag by downloading latest vscode.. and its working as expected. It would be great, if you can lower the version check if possible. Thank you once again to make this possible.
I am using this extension for a while and it's working great.
I am trying to add an option to Uncrustify to better sort import orders using PR 2710.
However the extension doesn't take
filename
into consideration when formatting. If the extension is using temporary file for formatting can it use the same name as that of the actual filename, so that the above functionality works fine. Thankyou