diff --git a/ktlint/src/main/kotlin/com/github/shyiko/ktlint/Main.kt b/ktlint/src/main/kotlin/com/github/shyiko/ktlint/Main.kt index 1e946062c4..65fecfea16 100644 --- a/ktlint/src/main/kotlin/com/github/shyiko/ktlint/Main.kt +++ b/ktlint/src/main/kotlin/com/github/shyiko/ktlint/Main.kt @@ -291,14 +291,15 @@ ${ByteArrayOutputStream().let { this.printUsage(it); it }.toString().trimEnd().s return generateSequence(fun (): File? { while (true) { val file = stack.pollLast() - if (file != null && file.isDirectory) { + if (file == null || file.isFile) { + return file + } + if (file.isDirectory) { val fileList = file.listFiles(filter) if (fileList != null) { stack.addAll(fileList) } - continue } - return file } }) }