From 88398e8ebef2109db3937c00bff63e119da7c2cf Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Tue, 7 Dec 2021 16:19:18 -0800 Subject: [PATCH] InputMethod: original string could be empty --- scalafmt-cli/src/main/scala/org/scalafmt/cli/InputMethod.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scalafmt-cli/src/main/scala/org/scalafmt/cli/InputMethod.scala b/scalafmt-cli/src/main/scala/org/scalafmt/cli/InputMethod.scala index f2dc198973..bd6988f292 100644 --- a/scalafmt-cli/src/main/scala/org/scalafmt/cli/InputMethod.scala +++ b/scalafmt-cli/src/main/scala/org/scalafmt/cli/InputMethod.scala @@ -91,7 +91,8 @@ object InputMethod { (code.linesIterator ++ last).toList.asJava } val a = jList(original, false) - val b = jList(revised, noEol(original.last)) // formatted always has EOL + // formatted always has EOL + val b = jList(revised, original.isEmpty || noEol(original.last)) val diff = difflib.DiffUtils.diff(a, b) if (diff.getDeltas.isEmpty) "" else {