From e2175e52397725c2bd86008dde0a48b8ecc6bb04 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Wed, 18 Jan 2017 15:35:23 +0300 Subject: [PATCH] IDEA-166734 Code folding should unfold when I hit F2 to find the next error/warning --- .../codeInsight/daemon/impl/GotoNextErrorHandler.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GotoNextErrorHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GotoNextErrorHandler.java index 136fb481ab1c..a880c77070c7 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GotoNextErrorHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GotoNextErrorHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,7 @@ import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings; import com.intellij.codeInsight.hint.HintManager; import com.intellij.codeInspection.InspectionsBundle; import com.intellij.lang.annotation.HighlightSeverity; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.ScrollType; -import com.intellij.openapi.editor.ScrollingModel; +import com.intellij.openapi.editor.*; import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiFile; @@ -126,6 +123,8 @@ public class GotoNextErrorHandler implements CodeInsightActionHandler { editor.getCaretModel().removeSecondaryCarets(); editor.getCaretModel().moveToOffset(offset); scrollingModel.scrollToCaret(scrollType); + FoldRegion regionAtOffset = editor.getFoldingModel().getCollapsedRegionAtOffset(offset); + if (regionAtOffset != null) editor.getFoldingModel().runBatchFoldingOperation(() -> regionAtOffset.setExpanded(true)); } scrollingModel.runActionOnScrollingFinished(