-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix infinite loop on Windows caused by checking path against "/". #802
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what a root-only file:
URL like C:/
on Windows looks like and I don't have a good way to test it. @compnerd does this look reasonable to you?
I think that it depends on what you are using. Particularly with swift-foundation, it should be |
@@ -415,7 +415,7 @@ public struct Configuration: Codable, Equatable { | |||
if FileManager.default.isReadableFile(atPath: candidateFile.path) { | |||
return candidateFile | |||
} | |||
} while candidateDirectory.path != "/" | |||
} while candidateDirectory.pathComponents.count > 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The concern that I have with this on Windows is that this would return true
for C:
and \
, both of which are relative paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems generic enough to work. It is unfortunate that Foundation doesn't have a isRoot
property.
…'t contain a `.swift-format` file swiftlang#802 this sort of infinite looping issue on Windows but introduced it on Unix platforms where `URL.deletingLastPathComponent` on `/` returns `/..`.
…'t contain a `.swift-format` file swiftlang#802 this sort of infinite looping issue on Windows but introduced it on Unix platforms where `URL.deletingLastPathComponent` on `/` returns `/..`.
…'t contain a `.swift-format` file swiftlang#802 this sort of infinite looping issue on Windows but introduced it on Unix platforms where `URL.deletingLastPathComponent` on `/` returns `/..`. # Conflicts: # Sources/SwiftFormat/API/Configuration.swift
…'t contain a `.swift-format` file swiftlang#802 this sort of infinite looping issue on Windows but introduced it on Unix platforms where `URL.deletingLastPathComponent` on `/` returns `/..`.
…'t contain a `.swift-format` file swiftlang#802 this sort of infinite looping issue on Windows but introduced it on Unix platforms where `URL.deletingLastPathComponent` on `/` returns `/..`.
…'t contain a `.swift-format` file swiftlang#802 this sort of infinite looping issue on Windows but introduced it on Unix platforms where `URL.deletingLastPathComponent` on `/` returns `/..`.
Should fix #694.