IDEA-323747 Printing fails (File | Print)

GitOrigin-RevId: cc2f8bd35bc9cb01ee311d727d72ddabab0c4889
This commit is contained in:
Alexey Kudravtsev
2023-07-31 18:28:09 +00:00
committed by intellij-monorepo-bot
parent bb41b95d53
commit 730867c2d1
@@ -2,9 +2,14 @@
package com.intellij.codeEditor.printing;
import com.intellij.codeInsight.daemon.LineMarkerInfo;
import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator;
import com.intellij.codeInsight.daemon.impl.HighlightingSessionImpl;
import com.intellij.codeInsight.daemon.impl.LineMarkersPass;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.markup.SeparatorPlacement;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.ProperTextRange;
import com.intellij.psi.PsiFile;
import com.intellij.util.MathUtil;
import org.jetbrains.annotations.NotNull;
@@ -16,14 +21,22 @@ import java.util.List;
final class FileSeparatorProvider {
@NotNull
static List<LineMarkerInfo<?>> getFileSeparators(@NotNull PsiFile file, @NotNull Document document) {
final List<LineMarkerInfo<?>> result = new ArrayList<>();
for (LineMarkerInfo<?> lineMarkerInfo : LineMarkersPass.queryLineMarkers(file, document)) {
if (lineMarkerInfo.separatorColor != null) {
result.add(lineMarkerInfo);
}
}
ApplicationManager.getApplication().assertIsNonDispatchThread();
ApplicationManager.getApplication().assertReadAccessAllowed();
List<LineMarkerInfo<?>> result = new ArrayList<>();
// need to run highlighting under DaemonProgressIndicator
DaemonProgressIndicator indicator = new DaemonProgressIndicator();
result.sort(Comparator.comparingInt(i -> getDisplayLine(i, document)));
ProgressManager.getInstance().executeProcessUnderProgress(() -> {
HighlightingSessionImpl.runInsideHighlightingSession(file, null, ProperTextRange.create(file.getTextRange()), false, __ -> {
for (LineMarkerInfo<?> lineMarkerInfo : LineMarkersPass.queryLineMarkers(file, document)) {
if (lineMarkerInfo.separatorColor != null) {
result.add(lineMarkerInfo);
}
}
result.sort(Comparator.comparingInt(i -> getDisplayLine(i, document)));
});
}, indicator);
return result;
}