nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.92k stars 639 forks source link

SwiftFormat: adjust `expandPath` to be more portable #1468

Closed compnerd closed 1 year ago

compnerd commented 1 year ago

Reuse the implementation of NSString's isAbsolutePath to determine if the path is absolute rather than re-implementing that logic inline. This allows use of SwiftFormat with the vknabel/SwiftFormat extension with Visual Studio Code on Windows.

We would previously attempt to check if the configuration path was absolute by checking for a leading / which does not represent an absolute path on Windows but rather a relative path (it is drive relative). We perform a bit more bridging here but get the portable behaviour without resorting to manually invoking IsPathRelativeW on the path representation. This also allows us to pick up the improvements to the path handling in Foundation for long paths without having to reconstruct special handling.

nicklockwood commented 1 year ago

@compnerd thanks!

btw, I'd be interested in adding Windows to the github CI build action so I don't accidentally break support for it, but I've not managed to get it working. Is that something you have any experience with?

compnerd commented 1 year ago

@nicklockwood sure! I can do one better - I can also help with getting an installer setup for actual releases beyond just the CI :)

nicklockwood commented 1 year ago

@compnerd That would be amazing!