diff --git a/scala/compiler-integration/src/org/jetbrains/plugins/scala/compiler/highlighting/CompilerMessages.scala b/scala/compiler-integration/src/org/jetbrains/plugins/scala/compiler/highlighting/CompilerMessages.scala index b691f168771..1e5b2de205f 100644 --- a/scala/compiler-integration/src/org/jetbrains/plugins/scala/compiler/highlighting/CompilerMessages.scala +++ b/scala/compiler-integration/src/org/jetbrains/plugins/scala/compiler/highlighting/CompilerMessages.scala @@ -14,7 +14,8 @@ private object CompilerMessages { case bspMessageTemplate(_, position) => position case line => line } - trimmedMessage.stripSuffix(suffix).trim + val noSuffix = trimmedMessage.stripSuffix(suffix).trim + if (noSuffix.isBlank) trimmedMessage else noSuffix } def isUnusedImport(description: String): Boolean = diff --git a/scala/compiler-integration/test/org/jetbrains/plugins/scala/compiler/highlighting/CompilerMessagesTest.scala b/scala/compiler-integration/test/org/jetbrains/plugins/scala/compiler/highlighting/CompilerMessagesTest.scala index 172cac4158f..de496f6c115 100644 --- a/scala/compiler-integration/test/org/jetbrains/plugins/scala/compiler/highlighting/CompilerMessagesTest.scala +++ b/scala/compiler-integration/test/org/jetbrains/plugins/scala/compiler/highlighting/CompilerMessagesTest.scala @@ -20,4 +20,27 @@ class CompilerMessagesTest { val actual = CompilerMessages.description(originalMessage) assertEquals(expected, actual) } + + @Test + def deprecationWarningsMessage(): Unit = { + val originalMessage = "there were 4 deprecation warnings; re-run with -deprecation for details\n\n" + val expected = "there were 4 deprecation warnings; re-run with -deprecation for details" + val actual = CompilerMessages.description(originalMessage) + assertEquals(expected, actual) + } + + @Test + def oneLineMessage(): Unit = { + val originalMessage = "This is a one line error message" + val actual = CompilerMessages.description(originalMessage) + assertEquals(originalMessage, actual) + } + + @Test + def blankAfterProcessing(): Unit = { + val originalMessage = "\n\nSome message \n " + val expected = "Some message" + val actual = CompilerMessages.description(originalMessage) + assertEquals(expected, actual) + } }