Skip to content

Commit a8d37ae

Browse files
committed
main Fix support for FileIterator when working directory is /
Added an additional check that tests to see if the working directory is root. swiftlang#862
1 parent 3ca1a18 commit a8d37ae

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/SwiftFormat/Utilities/FileIterator.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public struct FileIterator: Sequence, IteratorProtocol {
145145
// be displayed as relative paths. Otherwise, they will still be displayed as absolute
146146
// paths.
147147
let relativePath =
148-
path.hasPrefix(workingDirectory.path)
148+
path.hasPrefix(workingDirectory.path) && path.first != "/"
149149
? String(path.dropFirst(workingDirectory.path.count + 1))
150150
: path
151151
output =

0 commit comments

Comments
 (0)