For my plugin I need editor tests where some code is folded - lets say I want to have folded class within example.
Before being even able work with folding properties, I hit issue that my code that is foldable when pasted into Kotlin editor, but has no folding regions ({editor.foldingModel.allFoldRegions.size is 0) inside editor.foldingModel.
I tried to make it work with some crappy AI suggestions i.e. doHighlights, playing with codeFoldingManager, but to no avail.
Here is the code:
class FoldingTest : BasePlatformTestCase() {
fun testFolding() {
val code = """
import com.test.First
import com.test.Second
import com.test.Third
class MyClass {
fun foo() {
println("Hello")
}
}""".trimIndent()
println(code)
myFixture.configureByText("test.kt", code)
val editor = myFixture.editor
val settings = myFixture.editor.settings
editor.settings.isAutoCodeFoldingEnabled = true
editor.settings.isFoldingOutlineShown = true
myFixture.doHighlighting()
val codeFoldingManager = CodeFoldingManager.getInstance(myFixture.project)
codeFoldingManager.updateFoldRegions(myFixture.editor)
//here I expect 2 not 0
println("Number of fold regions: ${editor.foldingModel.allFoldRegions.size}")
}
}
I need to get class folded so that I can start running tests against my folding dependent plugin code.