void () { UISettings.getInstance().setEditorTabPlacement(UISettings.TABS_NONE); VirtualFile file = getFile("/src/Test.java"); assertNotNull(file); Assume.assumeTrue("JAVA".equals(file.getFileType().getName())); // otherwise, the folding would be incorrect FileEditor[] editors = manager.openFile(file, false); assertEquals(1, editors.length); assertTrue(editors[0] instanceof TextEditor); Editor editor = ((TextEditor)editors[0]).getEditor(); EditorTestUtil.waitForLoading(editor); final FoldingModel foldingModel = editor.getFoldingModel(); assertEquals(2, foldingModel.getAllFoldRegions().length); foldingModel.runBatchFoldingOperation(() -> { for (FoldRegion region : foldingModel.getAllFoldRegions()) { region.setExpanded(false); } }); int textLength = editor.getDocument().getTextLength(); editor.getCaretModel().moveToOffset(textLength); editor.getSelectionModel().setSelection(textLength - 1, textLength); manager.openFile(getFile("/src/1.txt"), false); assertEquals(1, manager.getEditors(file).length); editors = manager.openFile(file, false); assertEquals(1, editors.length); assertTrue(editors[0] instanceof TextEditor); editor = ((TextEditor)editors[0]).getEditor(); EditorTestUtil.waitForLoading(editor); assertEquals(textLength, editor.getCaretModel().getOffset()); assertEquals(textLength - 1, editor.getSelectionModel().getSelectionStart()); assertEquals(textLength, editor.getSelectionModel().getSelectionEnd()); }