in packages/core/src/models/Workbench.ts [81:96]
removeWorkspace(id: string) {
const findIndex = this.findWorkspaceIndexById(id)
if (findIndex > -1 && findIndex < this.workspaces.length) {
const findedWorkspace = this.workspaces[findIndex]
findedWorkspace.viewport.detachEvents()
this.workspaces.splice(findIndex, 1)
if (findedWorkspace === this.currentWorkspace) {
if (this.workspaces.length && this.workspaces[findIndex]) {
this.currentWorkspace = this.workspaces[findIndex]
} else {
this.currentWorkspace = this.workspaces[this.workspaces.length - 1]
}
}
this.engine.dispatch(new RemoveWorkspaceEvent(findedWorkspace))
}
}