src/extensions/default/CodeFolding/main.js
function init() {
        _isInitialized = true;

        foldCode.init();
        foldGutter.init();

        // Many CodeMirror modes specify which fold helper should be used for that language. For a few that
        // don't, we register helpers explicitly here. We also register a global helper for generic indent-based
        // folding, which cuts across all languages if enabled via preference.
        CodeMirror.registerGlobalHelper("fold", "selectionFold", function (mode, cm) {
            return prefs.getSetting("makeSelectionsFoldable");
        }, selectionFold);
        CodeMirror.registerGlobalHelper("fold", "indent", function (mode, cm) {
            return prefs.getSetting("alwaysUseIndentFold");
        }, indentFold);

        CodeMirror.registerHelper("fold", "handlebars", handlebarsFold);
        CodeMirror.registerHelper("fold", "htmlhandlebars", handlebarsFold);
        CodeMirror.registerHelper("fold", "htmlmixed", handlebarsFold);

        EditorManager.on("activeEditorChange.CodeFolding", onActiveEditorChanged);
        DocumentManager.on("documentRefreshed.CodeFolding", function (event, doc) {
            restoreLineFolds(doc._masterEditor);
        });

        ProjectManager.on("beforeProjectClose.CodeFolding beforeAppClose.CodeFolding", saveBeforeClose);

        //create menus
        codeFoldingMenuDivider = Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuDivider();
        Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_ALL);
        Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND_ALL);
        Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE);
        Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND);

        //register keybindings
        KeyBindingManager.addBinding(COLLAPSE_ALL, [ {key: collapseAllKey}, {key: collapseAllKeyMac, platform: "mac"} ]);
        KeyBindingManager.addBinding(EXPAND_ALL, [ {key: expandAllKey}, {key: expandAllKeyMac, platform: "mac"} ]);
        KeyBindingManager.addBinding(COLLAPSE, collapseKey);
        KeyBindingManager.addBinding(EXPAND, expandKey);


        // Add gutters & restore saved expand/collapse state in all currently open editors
        Editor.registerGutter(GUTTER_NAME, CODE_FOLDING_GUTTER_PRIORITY);
        Editor.forEveryEditor(function (editor) {
            enableFoldingInEditor(editor);
        });
    }
function init() {
        _isInitialized = true;

        foldCode.init();
        foldGutter.init();

        // Many CodeMirror modes specify which fold helper should be used for that language. For a few that
        // don't, we register helpers explicitly here. We also register a global helper for generic indent-based
        // folding, which cuts across all languages if enabled via preference.
        CodeMirror.registerGlobalHelper("fold", "selectionFold", function (mode, cm) {
            return prefs.getSetting("makeSelectionsFoldable");
        }, selectionFold);
        CodeMirror.registerGlobalHelper("fold", "indent", function (mode, cm) {
            return prefs.getSetting("alwaysUseIndentFold");
        }, indentFold);

        CodeMirror.registerHelper("fold", "handlebars", handlebarsFold);
        CodeMirror.registerHelper("fold", "htmlhandlebars", handlebarsFold);
        CodeMirror.registerHelper("fold", "htmlmixed", handlebarsFold);

        EditorManager.on("activeEditorChange.CodeFolding", onActiveEditorChanged);
        DocumentManager.on("documentRefreshed.CodeFolding", function (event, doc) {
            restoreLineFolds(doc._masterEditor);
        });

        ProjectManager.on("beforeProjectClose.CodeFolding beforeAppClose.CodeFolding", saveBeforeClose);

        //create menus
        codeFoldingMenuDivider = Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuDivider();
        Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_ALL);
        Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND_ALL);
        Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE);
        Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND);

        //register keybindings
        KeyBindingManager.addBinding(COLLAPSE_ALL, [ {key: collapseAllKey}, {key: collapseAllKeyMac, platform: "mac"} ]);
        KeyBindingManager.addBinding(EXPAND_ALL, [ {key: expandAllKey}, {key: expandAllKeyMac, platform: "mac"} ]);
        KeyBindingManager.addBinding(COLLAPSE, collapseKey);
        KeyBindingManager.addBinding(EXPAND, expandKey);


        // Add gutters & restore saved expand/collapse state in all currently open editors
        Editor.registerGutter(GUTTER_NAME, CODE_FOLDING_GUTTER_PRIORITY);
        Editor.forEveryEditor(function (editor) {
            enableFoldingInEditor(editor);
        });
    }
function init ( ) { _isInitialized = true ; foldCode . init ( ) ; foldGutter . init ( ) ; // Many CodeMirror modes specify which fold helper should be used for that language. For a few that // don't, we register helpers explicitly here. We also register a global helper for generic indent-based // folding, which cuts across all languages if enabled via preference. CodeMirror . registerGlobalHelper ( "fold" , "selectionFold" , function ( mode , cm ) { return prefs . getSetting ( "makeSelectionsFoldable" ) ; } , selectionFold ) ; CodeMirror . registerGlobalHelper ( "fold" , "indent" , function ( mode , cm ) { return prefs . getSetting ( "alwaysUseIndentFold" ) ; } , indentFold ) ; CodeMirror . registerHelper ( "fold" , "handlebars" , handlebarsFold ) ; CodeMirror . registerHelper ( "fold" , "htmlhandlebars" , handlebarsFold ) ; CodeMirror . registerHelper ( "fold" , "htmlmixed" , handlebarsFold ) ; EditorManager . on ( "activeEditorChange.CodeFolding" , onActiveEditorChanged ) ; DocumentManager . on ( "documentRefreshed.CodeFolding" , function ( event , doc ) { restoreLineFolds ( doc . _masterEditor ) ; } ) ; ProjectManager . on ( "beforeProjectClose.CodeFolding beforeAppClose.CodeFolding" , saveBeforeClose ) ; //create menus codeFoldingMenuDivider = Menus . getMenu ( Menus . AppMenuBar . VIEW_MENU ) . addMenuDivider ( ) ; Menus . getMenu ( Menus . AppMenuBar . VIEW_MENU ) . addMenuItem ( COLLAPSE_ALL ) ; Menus . getMenu ( Menus . AppMenuBar . VIEW_MENU ) . addMenuItem ( EXPAND_ALL ) ; Menus . getMenu ( Menus . AppMenuBar . VIEW_MENU ) . addMenuItem ( COLLAPSE ) ; Menus . getMenu ( Menus . AppMenuBar . VIEW_MENU ) . addMenuItem ( EXPAND ) ; //register keybindings KeyBindingManager . addBinding ( COLLAPSE_ALL , [ { key : collapseAllKey } , { key : collapseAllKeyMac , platform : "mac" } ] ) ; KeyBindingManager . addBinding ( EXPAND_ALL , [ { key : expandAllKey } , { key : expandAllKeyMac , platform : "mac" } ] ) ; KeyBindingManager . addBinding ( COLLAPSE , collapseKey ) ; KeyBindingManager . addBinding ( EXPAND , expandKey ) ; // Add gutters & restore saved expand/collapse state in all currently open editors Editor . registerGutter ( GUTTER_NAME , CODE_FOLDING_GUTTER_PRIORITY ) ; Editor . forEveryEditor ( function ( editor ) { enableFoldingInEditor ( editor ) ; } ) ; }
Enable code-folding functionality
Enable code - folding functionality