IDEA-141262 Action "Folding Code Block" sometimes does not work properly

This commit is contained in:
Dmitry Batrak
2015-06-10 11:15:52 +03:00
parent a2d603a4a6
commit 466ac1c61c
2 changed files with 32 additions and 2 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -1116,6 +1116,31 @@ class Foo {
\t}
}""");
}
public void testCollapseExistingButExpandedBlock() {
String text = '''class Foo {
void m {
if (true) {
System.out.println();
}
}
}
'''
configure text
myFixture.editor.caretModel.moveToOffset(text.indexOf("System"))
myFixture.performEditorAction("CollapseBlock")
myFixture.performEditorAction("ExpandAllRegions")
myFixture.editor.caretModel.moveToOffset(text.indexOf("System"))
myFixture.performEditorAction("CollapseBlock")
def topLevelRegions = ((FoldingModelEx)myFixture.editor.foldingModel).fetchTopLevel()
assert topLevelRegions.length == 1
assert topLevelRegions[0].startOffset == text.indexOf('{', text.indexOf("if"))
assert topLevelRegions[0].endOffset == text.indexOf('}', text.indexOf("if")) + 1
}
private int getFoldRegionsCount() {
return myFixture.editor.foldingModel.allFoldRegions.length