Consumer<Editor> (@NotNull XDebugSession debugSession, @NotNull PyStackFrame frame, @NotNull String exceptionType, @NotNull String errorMessage, boolean isTestSetUpFail) { return editor -> { InlayModel inlayModel = editor.getInlayModel(); Inlay<FailedTestInlayRenderer> inlay = inlayModel.addBlockElement( frame.getPosition().getOffset(), true, false, 0, new FailedTestInlayRenderer(exceptionType, errorMessage, isTestSetUpFail)); if (inlay == null) return; ourActiveInlays.putIfAbsent(debugSession, new ArrayList<>()); ourActiveInlays.get(debugSession).add(inlay); ComponentListener listener = new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { Rectangle inlayBounds = inlay.getBounds(); if (inlayBounds != null && e.getComponent().getWidth() != inlay.getBounds().width) { inlay.update(); } } }; editor.getComponent().addComponentListener(listener); ourEditorListeners.put(inlay, listener); if (isTestSetUpFail) { // Errors in test set up should be deleted after the session resumes since set up is called // multiple times and we don't want to stack up the inlays below the erroneous line. debugSession.addSessionListener(new XDebugSessionListener() { @Override public void sessionResumed() { Disposer.dispose(inlay); debugSession.removeSessionListener(this); } }); } }; }