void () { configureByText(PlainTextFileType.INSTANCE, "blah blah\n".repeat(1000) + "<caret>" + wordToAnnotate + "\n" + "balh blah\n".repeat(1000)); EditorImpl editor = (EditorImpl)getEditor(); editor.getScrollPane().getViewport().setSize(1000, 1000); DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true); editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); Point2D visualPoint = editor.offsetToPoint2D(editor.getCaretModel().getOffset()); editor.getScrollPane().getViewport().setViewPosition(new Point((int)visualPoint.getX(), (int)visualPoint.getY())); editor.getScrollPane().getViewport().setExtentSize(new Dimension(100, editor.getPreferredHeight() - (int)visualPoint.getY())); ProperTextRange visibleRange = editor.calculateVisibleRange(); assertTrue(visibleRange.toString(), visibleRange.getStartOffset() > 0); useAnnotatorsIn(PlainTextLanguage.INSTANCE, new MyRecordingAnnotator[]{new MiddleOfTextAnnotator()}, ()->{ MiddleOfTextAnnotator.doAnnotate = true; List<HighlightInfo> infos = doHighlighting(); HighlightInfo info = assertOneElement(infos); assertEquals("warning", info.getDescription()); MiddleOfTextAnnotator.doAnnotate = false; myDaemonCodeAnalyzer.restart(); assertEmpty(doHighlighting()); }); }