IDEA-72690 Auto Collapse File Header Code Folding seems broken

Corrected 'expanded' folding state processing for the regions that start at the zero offset
This commit is contained in:
Denis.Zhdanov
2011-08-22 18:51:28 +04:00
parent f539e5975e
commit 568003a86b
@@ -153,8 +153,16 @@ class UpdateFoldRegionsOperation implements Runnable {
if (caretOffset > myEditor.getDocument().getTextLength()) {
return false;
}
final int currentLine = document.getLineNumber(caretOffset);
caretInside = firstLine <= currentLine && currentLine <= lastLine;
if (caretOffset == 0 && myApplyDefaultState) {
// Caret is located at the zero position when the editor is just opened, so, any fold region that starts at the zero
// offset (e.g. file header provided by 'copyright' plugin) is always expanded. We want to avoid that, hence, corresponding
// control flow branch is introduced.
caretInside = false;
}
else {
final int currentLine = document.getLineNumber(caretOffset);
caretInside = firstLine <= currentLine && currentLine <= lastLine;
}
}
if (myApplyDefaultState) {