From f9ef4027201a94b0680976bf26b79abc8185c7fe Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 5 Sep 2012 15:14:37 +0400 Subject: [PATCH] assertion --- .../folding/impl/CodeFoldingManagerImpl.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/CodeFoldingManagerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/CodeFoldingManagerImpl.java index 9495a6bf8815..6a33a45fc5ee 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/CodeFoldingManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/CodeFoldingManagerImpl.java @@ -214,7 +214,8 @@ public class CodeFoldingManagerImpl extends CodeFoldingManager implements Projec final PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(document); if (file == null || !file.getViewProvider().isPhysical() && !ApplicationManager.getApplication().isUnitTestMode()) return; - if (!((FoldingModelEx)editor.getFoldingModel()).isFoldingEnabled()) return; + final FoldingModelEx foldingModel = (FoldingModelEx)editor.getFoldingModel(); + if (!foldingModel.isFoldingEnabled()) return; if (project.isDisposed() || editor.isDisposed() || !file.isValid()) return; PsiDocumentManager.getInstance(myProject).commitDocument(document); @@ -231,16 +232,21 @@ public class CodeFoldingManagerImpl extends CodeFoldingManager implements Projec @Override public void run() { if (myProject.isDisposed() || editor.isDisposed()) return; - DocumentFoldingInfo documentFoldingInfo = getDocumentFoldingInfo(document); - Editor[] editors = EditorFactory.getInstance().getEditors(document, myProject); - for (Editor otherEditor : editors) { - if (otherEditor == editor) continue; - documentFoldingInfo.loadFromEditor(otherEditor); - break; - } - documentFoldingInfo.setToEditor(editor); + foldingModel.runBatchFoldingOperation(new Runnable() { + @Override + public void run() { + DocumentFoldingInfo documentFoldingInfo = getDocumentFoldingInfo(document); + Editor[] editors = EditorFactory.getInstance().getEditors(document, myProject); + for (Editor otherEditor : editors) { + if (otherEditor == editor) continue; + documentFoldingInfo.loadFromEditor(otherEditor); + break; + } + documentFoldingInfo.setToEditor(editor); - documentFoldingInfo.clear(); + documentFoldingInfo.clear(); + } + }); } }); }