/* Code Studio — editor core Monaco instances, editor groups, tabs and file IO. The workbench chrome around it lives in workbench.js. */ /* ═══════════════════════════════════════════════════════════════════ Environment ═══════════════════════════════════════════════════════════════════ */ let editors = []; //All editor groups currently on screen let focusedEditor = "mainEditor"; //uuid of the focused editor group let loadedModels = []; //filepath -> monaco model, avoids duplicates let focusedFileInfo = []; let currentProjectFolder = null; //Virtual path of the opened project folder let selectedFolderItem = null; //Item the folder context menu acts on let selectedTabInfo = null; //Tab the tab context menu acts on let untitledCounter = 0; let editorGroupCounter = 1; //Hashcode used to tell a modified buffer from a saved one String.prototype.hashCode = function() { var hash = 0; if (this.length == 0) return hash; for (var i = 0; i < this.length; i++) { hash = ((hash << 5) - hash) + this.charCodeAt(i); hash = hash & hash; } return hash; } /* ═══════════════════════════════════════════════════════════════════ Editor group lifecycle ═══════════════════════════════════════════════════════════════════ */ function getEditor(uuid){ for (var i = 0; i < editors.length; i++){ if (editors[i].uuid == uuid) return editors[i]; } return undefined; } function getFocusedEditorObject(){ var editorObject = getEditor(focusedEditor); if (editorObject === undefined && editors.length > 0) editorObject = editors[0]; return editorObject; } /* The AMD loader turns a module id into a relative URL and lets the browser resolve it against the document URL. Anchoring it to the loader