Collapse All and Expand All in Ace Editor

25 views
Skip to first unread message

vanessa....@gmail.com

unread,
May 8, 2024, 2:37:38 PMMay 8
to Ajax.org Cloud9 Editor (Ace)
Hi,
Is there any configuration and shortcut keys to collapse all or expand all sections in a yaml in ace editor? Any pointer is greatly appreciated.

Vanessa

vanessa....@gmail.com

unread,
May 8, 2024, 4:17:24 PMMay 8
to Ajax.org Cloud9 Editor (Ace)
I am using foldAll and expandFolds to achieve this. However expandFolds only works at the top-level folds. It does not work for deeper folds. Is there any method that I can use to recursively and deeply expand all Folds

toggleFoldingAllCode(folding: boolean): void {
const aceSession = this.getAceEditor().getSession();
if (folding) {
aceSession.foldAll();
} else {
aceSession.expandFolds(aceSession.getAllFolds());
}
}

vanessa....@gmail.com

unread,
May 8, 2024, 4:20:45 PMMay 8
to Ajax.org Cloud9 Editor (Ace)
Never mind. I discovered that if I call expandFolds many times. It will unfold more folds at a deeper levels.

Harutyun Amirjanyan

unread,
May 9, 2024, 4:49:31 PMMay 9
to ace-d...@googlegroups.com
there is also removeFolds method for removing the folds instead of simply expanding them https://ajaxorg.github.io/ace-api-docs/classes/src_edit_session_folding.Folding.html#removeFolds
 editor.session.removeFolds(editor.session.getAllFolds())

editor.session.unfold(null, true)
Reply all
Reply to author
Forward
0 new messages