diff --git a/src/main/kotlin/org/polyfrost/intelliprocessor/editor/PreprocessorFolding.kt b/src/main/kotlin/org/polyfrost/intelliprocessor/editor/PreprocessorFolding.kt index 641fb82..2718090 100644 --- a/src/main/kotlin/org/polyfrost/intelliprocessor/editor/PreprocessorFolding.kt +++ b/src/main/kotlin/org/polyfrost/intelliprocessor/editor/PreprocessorFolding.kt @@ -42,6 +42,23 @@ class PreprocessorFolding : FoldingBuilderEx(), DumbAware { stack.addLast(directive) } + text.startsWith(directivePrefix + "else") || text.startsWith(directivePrefix + "elseif") -> { + val startDirective = stack.removeLastOrNull() + if (startDirective != null) { + val commentLine = document.getLineNumber(directive.textOffset) + if (commentLine > 0) { + val prevLineEnd = document.getLineEndOffset(commentLine - 1) + descriptors.add( + FoldingDescriptor( + startDirective, + TextRange(startDirective.textRange.startOffset, prevLineEnd) + ) + ) + stack.addLast(directive) + } + } + } + text.startsWith(directivePrefix + "endif") -> { val startDirective = stack.removeLastOrNull() if (startDirective != null) {