diff --git a/platform/platform-impl/src/com/intellij/notification/EventLog.java b/platform/platform-impl/src/com/intellij/notification/EventLog.java index 0ba18358cf37..88c37d54a8f3 100644 --- a/platform/platform-impl/src/com/intellij/notification/EventLog.java +++ b/platform/platform-impl/src/com/intellij/notification/EventLog.java @@ -235,10 +235,10 @@ public class EventLog implements Notifications { } private static void removeJavaNewLines(Document document, List lineSeparators, boolean hasHtml) { - String text = document.getText(); - int i = -1; + CharSequence text = document.getCharsSequence(); + int i = 0; while (true) { - i = text.indexOf('\n', i + 1); + i = StringUtil.indexOf(text, '\n', i); if (i < 0) break; document.deleteString(i, i + 1); if (!hasHtml) { diff --git a/platform/platform-tests/testSrc/com/intellij/notification/EventLogTest.groovy b/platform/platform-tests/testSrc/com/intellij/notification/EventLogTest.groovy index 5c0c049b42a9..3b1360036d49 100644 --- a/platform/platform-tests/testSrc/com/intellij/notification/EventLogTest.groovy +++ b/platform/platform-tests/testSrc/com/intellij/notification/EventLogTest.groovy @@ -74,4 +74,8 @@ class EventLogTest extends LightPlatformTestCase { assert EventLog.formatForLog(new Notification("xxx", 'title', "foo
Bar", NotificationType.ERROR)).message == 'title: foo // Bar' } + public void testManyNewlines() throws Exception { + assert EventLog.formatForLog(new Notification("xxx", 'title', "foo\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nbar", NotificationType.ERROR)).message == 'title: foo bar' + } + }