Search code examples
ace-editor

How to get folds line numbers


Is there any way to get line numbers of all lines in editor with "triangle" button (for folding/unfolding) in gutter, no matter if they are already folded or not?


Solution

  • See foldAll function. Since Ace recomputes fold data lazily, so you can go over all lines and do

    var foldWidgets = editor.session.foldWidgets
    var fw = foldWidgets[row]; // use cached value
    if (fw == null) // if it's not there recompute it
        fw = editor.session.getFoldWidget(row);