From 3a290433fbf4fc47ecd3e7b5e25950d3c80ec19e Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 2 Feb 2012 16:00:15 +0100 Subject: [PATCH] understand
as line separator --- .../src/com/intellij/notification/EventLog.java | 11 +++++------ .../com/intellij/notification/EventLogTest.groovy | 6 ++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/notification/EventLog.java b/platform/platform-impl/src/com/intellij/notification/EventLog.java index 310e5544c0e8..0ba18358cf37 100644 --- a/platform/platform-impl/src/com/intellij/notification/EventLog.java +++ b/platform/platform-impl/src/com/intellij/notification/EventLog.java @@ -46,6 +46,7 @@ import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentFactory; +import com.intellij.util.containers.CollectionFactory; import com.intellij.util.containers.hash.LinkedHashMap; import com.intellij.util.text.CharArrayUtil; import org.jetbrains.annotations.NonNls; @@ -58,6 +59,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Matcher; @@ -74,6 +76,7 @@ public class EventLog implements Notifications { private static final String A_CLOSING = ""; private static final Pattern TAG_PATTERN = Pattern.compile("<[^>]*>"); private static final Pattern A_PATTERN = Pattern.compile("]* )?href=[\"\']([^>]*)[\"\'][^>]*>"); + private static final Set NEW_LINES = CollectionFactory.newSet("
", "
", "
", "

", "

", "

"); public EventLog() { ApplicationManager.getApplication().getMessageBus().connect().subscribe(Notifications.TOPIC, this); @@ -188,11 +191,7 @@ public class EventLog implements Notifications { } hasHtml = true; - if ("
".equals(tagStart) || - "
".equals(tagStart) || - "

".equals(tagStart) || - "

".equals(tagStart) || - "

".equals(tagStart)) { + if (NEW_LINES.contains(tagStart)) { lineSeparators.add(document.createRangeMarker(TextRange.from(document.getTextLength(), 0))); } else if (!"".equals(tagStart) && !"".equals(tagStart) && !"".equals(tagStart) && !"".equals(tagStart)) { @@ -219,7 +218,7 @@ public class EventLog implements Notifications { if (offset < document.getTextLength()) { boolean spaceAfter = Character.isWhitespace(document.getCharsSequence().charAt(offset)); int next = CharArrayUtil.shiftForward(document.getCharsSequence(), offset, " \t"); - if (next < document.getTextLength() && Character.isUpperCase(document.getCharsSequence().charAt(next))) { + if (next < document.getTextLength() && !Character.isLowerCase(document.getCharsSequence().charAt(next))) { document.insertString(offset, (spaceBefore ? "" : " ") + "//" + (spaceAfter ? "" : " ")); continue; } diff --git a/platform/platform-tests/testSrc/com/intellij/notification/EventLogTest.groovy b/platform/platform-tests/testSrc/com/intellij/notification/EventLogTest.groovy index e15a4d732592..5c0c049b42a9 100644 --- a/platform/platform-tests/testSrc/com/intellij/notification/EventLogTest.groovy +++ b/platform/platform-tests/testSrc/com/intellij/notification/EventLogTest.groovy @@ -68,4 +68,10 @@ class EventLogTest extends LightPlatformTestCase { assert entry.message == 'link: content (show balloon)' } + public void testVariousNewlines() throws Exception { + assert EventLog.formatForLog(new Notification("xxx", 'title', "foo
bar", NotificationType.ERROR)).message == 'title: foo bar' + assert EventLog.formatForLog(new Notification("xxx", 'title', "foo
/bar", NotificationType.ERROR)).message == 'title: foo // /bar' + assert EventLog.formatForLog(new Notification("xxx", 'title', "foo
Bar", NotificationType.ERROR)).message == 'title: foo // Bar' + } + }