correct link offsets in TeamCity notifications

This commit is contained in:
peter
2012-02-20 18:45:54 +01:00
parent 5edbfb396c
commit b178b95992
2 changed files with 12 additions and 1 deletions
@@ -234,8 +234,9 @@ public class EventLog implements Notifications {
int linkEnd = content.indexOf(A_CLOSING, tagMatcher.end());
if (linkEnd > 0) {
String linkText = content.substring(tagMatcher.end(), linkEnd).replaceAll(TAG_PATTERN.pattern(), "");
int linkStart = document.getTextLength();
appendText(document, linkText);
links.put(document.createRangeMarker(new TextRange(document.getTextLength() - linkText.length(), document.getTextLength())),
links.put(document.createRangeMarker(new TextRange(linkStart, document.getTextLength())),
new NotificationHyperlinkInfo(notification, href));
content = content.substring(linkEnd + A_CLOSING.length());
continue;
@@ -107,4 +107,14 @@ class EventLogTest extends LightPlatformTestCase {
\tbar'''
}
public void testTeamCityLink() {
def entry = format('title', '''<p>You are assigned for investigation of a test failure<br/>FtlFixesTest.testToplevelVariableLocal (IDEA Trunk), assigned by Roman Shevchenko<br/></p>
<p><a href='#'>Details &raquo;</a></p>''')
assert entry.message == '''title
\tYou are assigned for investigation of a test failure
\tFtlFixesTest.testToplevelVariableLocal (IDEA Trunk), assigned by Roman Shevchenko
\tDetails >>'''
assert entry.links.collect { it.first } == [new TextRange(144, 154)]
}
}