Closed grodtron closed 1 year ago
How strange!
I'm okay with just reversing that check, may regress for some cases but if so they were always working for the wrong reasons, and we could take those issues in stride. The ideal would be also having the check analyze the exit code and stderr to distinguish straightforward "ktfmt not available" cases from other errors, and logging a more detailed warning with actual errors from command in that case (so if we do regress for someone, we won't have to go hunting for more repro details to understand how to fix it on their system).
Cool, I am happy to submit a PR for this in that case, and add that additional logging 👍
I spent some more time looking into this, and it seems that the failure cases actually always already end up in the catch block of the try catch, where a nice error is already logged. A couple examples:
ktfmt unavailable, check jar file in `java -jar foobar.jar -`: ERROR(ShellError): Error running: java -jar foobar.jar -
Error: Unable to access jarfile foobar.jar
ktfmt unavailable, check jar file in `java -xx -`: ERROR(ShellError): Error running: java -xx -
Unrecognized option: -xx
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Since there's already decent error messages, I am just submitting my change directly as a CR - but please let me know if you'd like any modifications to it!
Describe the bug When trying to use
ktfmt
I get the following error:However, if I reverse the conditional check like this then everything works fine. I feel like I may be missing something since I would have thought others would encounter this issue, but I have tested this locally and it fixes the issue for me. If you agree that this change makes sense I can sign the CLA and make a pull request, or feel free to just make the (one character) change directly.
To Reproduce Minimal vimrc snippet, does not include installing codefmt itself:
Steps to reproduce the behavior:
:w
)Expected behavior The file should be formatted
OS (version) Linux
Additional context n/a