mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
print multiple links correctly
This commit is contained in:
+16
-4
@@ -25,7 +25,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.*;
|
||||
|
||||
public final class TestProxyPrinterProvider {
|
||||
|
||||
@@ -96,18 +96,30 @@ public final class TestProxyPrinterProvider {
|
||||
throw new RuntimeException("Error while applying " + myFilter + " to '"+line+"'", t);
|
||||
}
|
||||
if (result != null) {
|
||||
for (Filter.ResultItem item : result.getResultItems()) {
|
||||
defaultPrint(line.substring(0, item.getHighlightStartOffset()), contentType);
|
||||
List<Filter.ResultItem> items = sort(result.getResultItems());
|
||||
int lastOffset = 0;
|
||||
for (Filter.ResultItem item : items) {
|
||||
defaultPrint(line.substring(lastOffset, item.getHighlightStartOffset()), contentType);
|
||||
String linkText = line.substring(item.getHighlightStartOffset(), item.getHighlightEndOffset());
|
||||
printHyperlink(linkText, item.getHyperlinkInfo());
|
||||
defaultPrint(line.substring(item.getHighlightEndOffset()), contentType);
|
||||
lastOffset = item.getHighlightEndOffset();
|
||||
}
|
||||
defaultPrint(line.substring(lastOffset), contentType);
|
||||
}
|
||||
else {
|
||||
defaultPrint(line, contentType);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<Filter.ResultItem> sort(@NotNull List<Filter.ResultItem> items) {
|
||||
if (items.size() <= 1) {
|
||||
return items;
|
||||
}
|
||||
List<Filter.ResultItem> copy = new ArrayList<>(items);
|
||||
Collections.sort(copy, Comparator.comparingInt(Filter.ResultItem::getHighlightStartOffset));
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user