vknabel / vscode-apple-swift-format

VS Code extension for formatting Swift code with apple/swift-format.
https://marketplace.visualstudio.com/items?itemName=vknabel.vscode-apple-swift-format
MIT License
31 stars 7 forks source link

Formatting crashed with latest build of swift-format for swift 5.2 #1

Closed artemkalinovsky closed 4 years ago

artemkalinovsky commented 4 years ago

I've built swift-format from https://github.com/apple/swift-format and installed your extension, but when I try to apply formatting, VS Code gives me error:

An unknown error occurred. Command failed: /usr/local/bin/swift-format 2020-04-07 18:10:23.478 swift-format[27024:309786] Terminating app due to uncaught exception 'NSFileHandleOperationException', reason: ' -[_NSStdIOFileHandle synchronizeFile]: Operation not supported' *** First throw call stack: ( 0 CoreFoundation 0x00007fff37cf4d07 __exceptionPreprocess + 250 1 libobjc.A.dylib 0x00007fff70a195bf objc_exception_throw + 48 2 Foundation 0x00007fff3a44a6ca -[NSConcreteFileHandle readDataUpToLength:error:] + 0 3 Foundation 0x00007fff3a44a412 -[NSConcreteFileHandle init] + 0 4 Foundation 0x00007fff3a2fc42c -[NSConcreteFileHandle synchronizeFile] + 63 5 swift-format 0x000000010a5fd331 $s12swift_format0B4Main33_D4951910FE263E47A548B8CE21C9EC27LL13configuration10sourceFile16assumingFilename7inPlace21ignoreUnparsableFiles12debugOptions16diagnosticEnginey24SwiftFormatConfiguration13ConfigurationV_So12NSFileHandleCSSSgS2b0Z6Format05DebugW0V0Z6Syntax010DiagnosticY0CtF + 1761 6 swift-format 0x000000010a5fcbbc $s12swift_format18SwiftFormatCommandV0D0V3runyyKF + 3548 7 swift-format 0x000000010a6011fc $s12swift_format18SwiftFormatCommandV10LegacyMainV3runyyKF + 1612 8 swift-format 0x000000010a601720 $s12swift_format18SwiftFormatCommandV10LegacyMainV14ArgumentParser08ParsableE0AafGP3runyyKFTW + 48 9 swift-format 0x000000010a2ebb75 $s14ArgumentParser15ParsableCommandPAAE4mainys5NeverOSaySSGSgFZ + 85 10 swift-format 0x000000010a5f9460 main + 32 11 libdyld.dylib 0x00007fff71bc0cc9 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException

Is this because extension isn't supporting swift 5.2 toolchain yet?

Thanks for help

vknabel commented 4 years ago

Hi @artemkalinovsky!

Does running swift-format from your terminal work? You might need to recompile swift-format. Additionally only certain Swift and swift-format tags work together.

artemkalinovsky commented 4 years ago

I've tried to recompile swift-format from master brach after they updated it 4 days ago and now plugin works brilliant:)