How to delete Workspaces? [9.1]

I’ve been playing around with the all new workspace-manager introduced in 9.1

I figured how to create new workspaces and how to load them, but how can I delete unused ones?

Hey @console,

In my infinite wisdom I decided that that functionality wasn’t needed. I now see that was a bad decision on my part and I would like to make amends. The following is the code for a macro that will add a menu entry to the File that named Manage Workspaces. You’ll be able to Alt + F, M to trigger it using your keyboard (short cut for accessing menu items):

ko.workspace2.manageWorkspaces = function ko_workspace2_manageWorkspace(){
    var workSpaceMRUList = ko.mru.getAll("mruWorkspaceList");
    workspaceName = ko.dialogs.selectFromList("Manage Workspaces",
                                         "Select Workspace to remove",
                                         workSpaceMRUList,
                                         "one", /*selectionCondition*/
                                         null, /*stringifier*/
                                         null, /*doNotAskPref*/
                                         false, /*yesNoCancel*/
                                         ["remove","cancel"], /*buttons*/
                                         0);   /*selectedIndex*/
    ko.workspace2.deleteWorkspace(workspaceName);
}

ko.workspace2.deleteWorkspace = function ko_workspace2_deleteWorkspace(workspaceName){
    //Get all workspace prefs
    workspacePrefs = ko.prefs.getPref("workspace2");
    // Delete the specific workspace pref set
    workspacePrefs.deletePref(workspaceName);
    // delete the mru entry
    ko.mru.deleteValue("mruWorkspaceList",workspaceName);
}

ko.workspace2.injectDOM = function(){
    var menuAtts = {id:"menu_workspace_manager",
                    accesskey:"M",
                    label:"Workspace Manager",
                    oncommand:"ko.workspace2.manageWorkspaces()"};
    
    var file_menu = document.getElementById("popup_file");    
    var files_refresher_sep = document.getElementById("file_refresh_menuseparator");
    var spacemenu = xtk.domutils.newElement("menuitem", menuAtts);
    file_menu.insertBefore(spacemenu, files_refresher_sep);
}

ko.workspace2.injectDOM();
ko.uilayout.cloneUnifiedMenuItems()

Edit: missing from hamburger menu.
Wasn’t removing pref set along with most recently used (mru) list

Here are the How to write a Komodo Macro docs just in case you or someone else isn’t sure how to make a macro.

I’ll add this to the workspace code in the repo for the next release as well so you won’t need the macro any more.

  • Carey

Thank you @careyh, excellent script. Was able to remove my unwanted workspaces perfectly.