diff --git a/notes/0.13.6.md b/notes/0.13.6.md index d7074225e..1ddc94e59 100644 --- a/notes/0.13.6.md +++ b/notes/0.13.6.md @@ -47,6 +47,7 @@ [1516]: https://github.com/sbt/sbt/pull/1516 [1465]: https://github.com/sbt/sbt/issues/1465 [1524]: https://github.com/sbt/sbt/issues/1524 + [1530]: https://github.com/sbt/sbt/issues/1530 [@dansanduleac]: https://github.com/dansanduleac [@2m]: https://github.com/2m @@ -108,7 +109,7 @@ - Fixes `build.sbt` errors causing `ArrayIndexOutOfBoundsException` due to invalid source in position. [#1181][1181] by [@eed3si9n][@eed3si9n] - Fixes config-classes leak in loading build files. [#1524][1524] by [@jsuereth][@jsuereth] - Fixes name-conflicts in hashed settings class files. [#1465][1465] by [@jsuereth][@jsuereth] - +- Fixes `NullPointerError` in tab completion by `FileExamples`. [#1530][1530] by [@eed3si9n][@eed3si9n] ### Maven Central Repository defaults to HTTPS diff --git a/util/complete/src/main/scala/sbt/complete/ExampleSource.scala b/util/complete/src/main/scala/sbt/complete/ExampleSource.scala index 6d0469aa0..52d96246b 100644 --- a/util/complete/src/main/scala/sbt/complete/ExampleSource.scala +++ b/util/complete/src/main/scala/sbt/complete/ExampleSource.scala @@ -1,7 +1,7 @@ package sbt.complete import java.io.File -import sbt.IO._ +import sbt.IO /** * These sources of examples are used in parsers for user input completion. An example of such a source is the @@ -48,9 +48,9 @@ class FileExamples(base: File, prefix: String = "") extends ExampleSource { override def withAddedPrefix(addedPrefix: String): FileExamples = new FileExamples(base, prefix + addedPrefix) protected def files(directory: File): Stream[String] = { - val childPaths = directory.listFiles().toStream - val prefixedDirectChildPaths = childPaths.map(relativize(base, _).get).filter(_ startsWith prefix) - val dirsToRecurseInto = childPaths.filter(_.isDirectory).map(relativize(base, _).get).filter(dirStartsWithPrefix) + val childPaths = IO.listFiles(directory).toStream + val prefixedDirectChildPaths = childPaths map { IO.relativize(base, _).get } filter { _ startsWith prefix } + val dirsToRecurseInto = childPaths filter { _.isDirectory } map { IO.relativize(base, _).get } filter { dirStartsWithPrefix } prefixedDirectChildPaths append dirsToRecurseInto.flatMap(dir => files(new File(base, dir))) } diff --git a/util/complete/src/test/scala/sbt/complete/FileExamplesTest.scala b/util/complete/src/test/scala/sbt/complete/FileExamplesTest.scala index 03b495bf0..effd9be78 100644 --- a/util/complete/src/test/scala/sbt/complete/FileExamplesTest.scala +++ b/util/complete/src/test/scala/sbt/complete/FileExamplesTest.scala @@ -80,8 +80,7 @@ class FileExamplesTest extends Specification { (childDirectories ++ nestedDirectories).map(_.mkdirs()) (childFiles ++ nestedFiles).map(_.createNewFile()) - // NOTE: Creating a new file here because `tempDir.listFiles()` returned an empty list. - baseDir = new File(tempDir.getCanonicalPath) + baseDir = tempDir } private def toChildFiles(baseDir: File, files: List[String]): List[File] = files.map(new File(baseDir, _))