From 23957d7f6679c984cf490ad60e72c2db5c2a15e3 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 11 Dec 2013 20:37:52 -0800 Subject: [PATCH 01/23] WIP: Make atom global a telepath model Specs seem to be green but hang on what I'm assuming to be a long GC pause near the end. I need to investigate what's going on memory wise. --- package.json | 2 +- spec/atom-spec.coffee | 2 +- spec/spec-bootstrap.coffee | 2 +- spec/spec-helper.coffee | 25 +- src/atom.coffee | 411 +++++++++++++++----------------- src/pane-axis.coffee | 2 +- src/pane-container.coffee | 2 +- src/pane.coffee | 2 +- src/site-shim.coffee | 9 +- src/window-bootstrap.coffee | 4 +- src/window-event-handler.coffee | 2 +- src/workspace-view.coffee | 2 +- 12 files changed, 224 insertions(+), 241 deletions(-) diff --git a/package.json b/package.json index 70f24b368..272d82bb9 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "season": "0.14.0", "semver": "1.1.4", "space-pen": "2.0.1", - "telepath": "0.70.0", + "telepath": "0.71.0", "temp": "0.5.0", "underscore-plus": "0.5.0" }, diff --git a/spec/atom-spec.coffee b/spec/atom-spec.coffee index 1615ce689..24b646b95 100644 --- a/spec/atom-spec.coffee +++ b/spec/atom-spec.coffee @@ -442,7 +442,7 @@ describe "the `atom` global", -> describe ".isReleasedVersion()", -> it "returns false if the version is a SHA and true otherwise", -> version = '0.1.0' - spyOn(atom, 'getVersion').andCallFake -> version + spyOn(atom.constructor, 'getVersion').andCallFake -> version expect(atom.isReleasedVersion()).toBe true version = '36b5518' expect(atom.isReleasedVersion()).toBe false diff --git a/spec/spec-bootstrap.coffee b/spec/spec-bootstrap.coffee index f2b2fd7fe..8e877ce04 100644 --- a/spec/spec-bootstrap.coffee +++ b/spec/spec-bootstrap.coffee @@ -4,7 +4,7 @@ require('crash-reporter').start(productName: 'Atom', companyName: 'GitHub') try require '../src/window' Atom = require '../src/atom' - window.atom = new Atom() + window.atom = Atom.loadOrCreate('spec') window.atom.show() unless atom.getLoadSettings().exitWhenDone {runSpecSuite} = require './jasmine-helper' diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 74d95c431..520d7b50b 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -1,6 +1,6 @@ require '../src/window' -atom.setUpEnvironment('spec') -atom.restoreDimensions() +atom.initialize() +atom.restoreWindowDimensions() require '../vendor/jasmine-jquery' path = require 'path' @@ -27,9 +27,8 @@ keyBindingsToRestore = atom.keymap.getKeyBindings() $(window).on 'core:close', -> window.close() $(window).on 'unload', -> - atom.windowMode = 'spec' - atom.getWindowState().set('dimensions', atom.getDimensions()) - atom.saveWindowState() + atom.storeWindowDimensions() + atom.saveSync() $('html,body').css('overflow', 'auto') jasmine.getEnv().addEqualityTester(_.isEqual) # Use underscore's definition of equality for toEqual assertions @@ -50,15 +49,15 @@ if specDirectory beforeEach -> $.fx.off = true projectPath = specProjectPath ? path.join(@specDirectory, 'fixtures') - atom.project = atom.getWindowState().set('project', new Project(path: projectPath)) + atom.project = atom.project = new Project(path: projectPath) atom.keymap.keyBindings = _.clone(keyBindingsToRestore) window.resetTimeouts() atom.packages.packageStates = {} serializedWindowState = null - spyOn(atom, 'saveWindowState').andCallFake -> serializedWindowState = @getWindowState().serialize() - spyOn(atom, 'loadSerializedWindowState').andCallFake -> serializedWindowState + + spyOn(atom, 'saveSync') atom.syntax.clearGrammarOverrides() atom.syntax.clearProperties() @@ -109,13 +108,17 @@ afterEach -> atom.workspaceView?.remove?() atom.workspaceView = null + atom.state.remove('workspaceView') atom.project?.destroy?() atom.project = null + console.log atom.state.has('packageStates') + + $('#jasmine-content').empty() unless window.debugContent - delete atom.windowState - jasmine.unspy(atom, 'saveWindowState') + + jasmine.unspy(atom, 'saveSync') ensureNoPathSubscriptions() atom.syntax.off() waits(0) # yield to ui thread to make screen update more frequently @@ -134,7 +137,7 @@ jasmine.StringPrettyPrinter.prototype.emitObject = (obj) -> emitObject.call(this, obj) jasmine.unspy = (object, methodName) -> - throw new Error("Not a spy") unless object[methodName].originalValue? + throw new Error("Not a spy") unless object[methodName].hasOwnProperty('originalValue') object[methodName] = object[methodName].originalValue addCustomMatchers = (spec) -> diff --git a/src/atom.coffee b/src/atom.coffee index 9a586434c..79a3837f9 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -10,13 +10,10 @@ app = remote.require 'app' _ = require 'underscore-plus' telepath = require 'telepath' -{Document} = telepath +{Document, Model} = telepath fs = require 'fs-plus' -{Subscriber} = require 'emissary' {$} = require './space-pen-extensions' -DeserializerManager = require './deserializer-manager' -Package = require './package' SiteShim = require './site-shim' WindowEventHandler = require './window-event-handler' @@ -37,24 +34,103 @@ WindowEventHandler = require './window-event-handler' # * `atom.syntax` - A {Syntax} instance # * `atom.themes` - A {ThemeManager} instance module.exports = -class Atom - Subscriber.includeInto(this) +class Atom extends Model + # Public: Load or create the Atom environment in the given mode + # + # - mode: Pass 'editor' or 'spec' depending on the kind of environment you + # want to build. + # + # Returns an Atom instance, fully initialized + @loadOrCreate: (mode) -> + telepath.devMode = not @isReleasedVersion() - # Private: - constructor: -> - @loadTime = null - @workspaceViewParentSelector = 'body' + if documentState = @loadDocumentState(mode) + environment = @deserialize(documentState) + + environment ? @createAsRoot({mode}) + + # Private: Loads and returns the serialized state corresponding to this window + # if it exists; otherwise returns undefined. + @loadDocumentState: (mode) -> + statePath = @getStatePath(mode) + + if fs.existsSync(statePath) + try + documentStateString = fs.readFileSync(statePath, 'utf8') + catch error + console.warn "Error reading window state: #{statePath}", error.stack, error + else + documentStateString = @getLoadSettings().windowState + + try + JSON.parse(documentStateString) if documentStateString? + catch error + console.warn "Error parsing window state: #{statePath}", error.stack, error + + # Private: Returns the path where the state for the current window will be + # located if it exists. + @getStatePath: (mode) -> + switch mode + when 'spec' + filename = 'spec' + when 'editor' + {initialPath} = @getLoadSettings() + if initialPath + sha1 = crypto.createHash('sha1').update(initialPath).digest('hex') + filename = "editor-#{sha1}" + + if filename + path.join(@getStorageDirPath(), filename) + else + null + + # Public: Get the directory path to Atom's configuration area. + # + # Returns the absolute path to ~/.atom + @getConfigDirPath: -> + @configDirPath ?= fs.absolute('~/.atom') + + # Public: Get the path to Atom's storage directory. + # + # Returns the absolute path to ~/.atom/storage + @getStorageDirPath: -> + @storageDirPath ?= path.join(@getConfigDirPath(), 'storage') + + # Private: Returns the load settings hash associated with the current window. + @getLoadSettings: -> + _.deepClone(@loadSettings ?= _.deepClone(@getCurrentWindow().loadSettings)) + + # Public: + @getCurrentWindow: -> + remote.getCurrentWindow() + + # Public: Get the version of the Atom application. + @getVersion: -> + app.getVersion() + + # Public: Determine whether the current version is an official release. + @isReleasedVersion: -> + not /\w{7}/.test(@getVersion()) # Check if the release is a 7-character SHA prefix + + @properties + mode: null + project: null + + workspaceViewParentSelector: 'body' + + # Private: Called by telepath. I'd like this to be merged with initialize eventually. + created: -> + DeserializerManager = require './deserializer-manager' @deserializers = new DeserializerManager() - # Private: Initialize all the properties in this object. + # Public: Sets up the basic services that should be available in all modes + # (both spec and application). Call after this instance has been assigned to + # the `atom` global. initialize: -> @unsubscribe() @setBodyPlatformClass() - {devMode, resourcePath} = atom.getLoadSettings() - configDirPath = @getConfigDirPath() - - telepath.devMode = not @isReleasedVersion() + @loadTime = null Config = require './config' Keymap = require './keymap' @@ -64,115 +140,30 @@ class Atom ThemeManager = require './theme-manager' ContextMenuManager = require './context-menu-manager' MenuManager = require './menu-manager' + {devMode, resourcePath} = @getLoadSettings() + configDirPath = @getConfigDirPath() @config = new Config({configDirPath, resourcePath}) @keymap = new Keymap({configDirPath, resourcePath}) @packages = new PackageManager({devMode, configDirPath, resourcePath}) - - @subscribe @packages, 'activated', => @watchThemes() @themes = new ThemeManager({packageManager: @packages, configDirPath, resourcePath}) @contextMenu = new ContextMenuManager(devMode) @menu = new MenuManager({resourcePath}) @pasteboard = new Pasteboard() - @syntax = @deserializers.deserialize(@getWindowState('syntax')) ? new Syntax() + @syntax = @deserializers.deserialize(@state.get('syntax')) ? new Syntax() + @site = new SiteShim(this) - # Private: This method is called in any window needing a general environment, including specs - setUpEnvironment: (@windowMode) -> - @initialize() + @subscribe @packages, 'activated', => @watchThemes() - # Private: - setBodyPlatformClass: -> - document.body.classList.add("platform-#{process.platform}") - - # Public: Create a new telepath model. We won't need to define this method when - # the atom global is a telepath model itself because all model subclasses inherit - # a create method. - create: (model) -> - @site.createDocument(model) - - # Public: Get the current window - getCurrentWindow: -> - remote.getCurrentWindow() - - # Public: Get the dimensions of this window. - # - # Returns an object with x, y, width, and height keys. - getDimensions: -> - browserWindow = @getCurrentWindow() - [x, y] = browserWindow.getPosition() - [width, height] = browserWindow.getSize() - {x, y, width, height} - - # Public: Set the dimensions of the window. - # - # The window will be centered if either the x or y coordinate is not set - # in the dimensions parameter. - # - # * dimensions: - # + x: - # The new x coordinate. - # + y: - # The new y coordinate. - # + width: - # The new width. - # + height: - # The new height. - setDimensions: ({x, y, width, height}) -> - browserWindow = @getCurrentWindow() - browserWindow.setSize(width, height) - if x? and y? - browserWindow.setPosition(x, y) - else - browserWindow.center() - - # Private: - restoreDimensions: -> - dimensions = @getWindowState().getObject('dimensions') - unless dimensions?.width and dimensions?.height - {height, width} = @getLoadSettings().initialSize ? {} - height ?= screen.availHeight - width ?= Math.min(screen.availWidth, 1024) - dimensions = {width, height} - @setDimensions(dimensions) - - # Public: Get the load settings for the current window. - # - # Returns an object containing all the load setting key/value pairs. - getLoadSettings: -> - @loadSettings ?= _.deepClone(@getCurrentWindow().loadSettings) - _.deepClone(@loadSettings) - - # Private: - deserializeProject: -> Project = require './project' - @project = @getWindowState('project') - unless @project instanceof Project - @project = new Project(path: @getLoadSettings().initialPath) - @setWindowState('project', @project) + TextBuffer = require './text-buffer' + TokenizedBuffer = require './tokenized-buffer' + DisplayBuffer = require './display-buffer' + Editor = require './editor' + @registerModelClasses(Project, TextBuffer, TokenizedBuffer, DisplayBuffer, Editor) - # Private: - deserializeWorkspaceView: -> - WorkspaceView = require './workspace-view' - state = @getWindowState() - @workspaceView = @deserializers.deserialize(state.get('workspaceView')) - unless @workspaceView? - @workspaceView = new WorkspaceView() - state.set('workspaceView', @workspaceView.getState()) - $(@workspaceViewParentSelector).append(@workspaceView) - # Private: - deserializePackageStates: -> - state = @getWindowState() - @packages.packageStates = state.getObject('packageStates') ? {} - state.remove('packageStates') - - # Private: - deserializeEditorWindow: -> - @deserializePackageStates() - @deserializeProject() - @deserializeWorkspaceView() - - # Private: This method is only called when opening a real application window + # Private: Call this method when establishing a real application window. startEditorWindow: -> if process.platform is 'darwin' CommandInstaller = require './command-installer' @@ -180,7 +171,7 @@ class Atom CommandInstaller.installApmCommand() @windowEventHandler = new WindowEventHandler - @restoreDimensions() + @restoreWindowDimensions() @config.load() @config.setDefaults('core', require('./workspace-view').configDefaults) @config.setDefaults('editor', require('./editor-view').configDefaults) @@ -200,33 +191,62 @@ class Atom @displayWindow() + # Private: + saveSync: -> + if statePath = @constructor.getStatePath(@mode) + super(statePath) + else + @getCurrentWindow().loadSettings.windowState = JSON.stringify(@serializeForPersistence()) + + # Private: + setBodyPlatformClass: -> + document.body.classList.add("platform-#{process.platform}") + + # Public: Get the load settings for the current window. + # + # Returns an object containing all the load setting key/value pairs. + getLoadSettings: -> + @constructor.getLoadSettings() + + # Private: + deserializeProject: -> + Project = require './project' + @project ?= new Project(path: @getLoadSettings().initialPath) + + # Private: + deserializeWorkspaceView: -> + WorkspaceView = require './workspace-view' + @workspaceView = @deserializers.deserialize(@state.get('workspaceView')) + unless @workspaceView? + @workspaceView = new WorkspaceView() + @state.set('workspaceView', @workspaceView.getState()) + $(@workspaceViewParentSelector).append(@workspaceView) + + # Private: + deserializePackageStates: -> + @packages.packageStates = @state.getObject('packageStates') ? {} + @state.remove('packageStates') + + # Private: + deserializeEditorWindow: -> + @deserializePackageStates() + @deserializeProject() + @deserializeWorkspaceView() + # Private: unloadEditorWindow: -> return if not @project and not @workspaceView - windowState = @getWindowState() - windowState.set('project', @project) - windowState.set('syntax', @syntax.serialize()) - windowState.set('workspaceView', @workspaceView.serialize()) + @state.set('syntax', @syntax.serialize()) + @state.set('workspaceView', @workspaceView.serialize()) @packages.deactivatePackages() - windowState.set('packageStates', @packages.packageStates) - @saveWindowState() + @state.set('packageStates', @packages.packageStates) + @saveSync() @workspaceView.remove() @project.destroy() @windowEventHandler?.unsubscribe() @windowState = null - # Set up the default event handlers and menus for a non-editor window. - # - # This can be used by packages to have a minimum level of keybindings and - # menus available when not using the standard editor window. - # - # This should only be called after setUpEnvironment() has been called. - setUpDefaultEvents: -> - @windowEventHandler = new WindowEventHandler - @keymap.loadBundledKeymaps() - @menu.update() - # Private: loadThemes: -> @themes.load() @@ -239,6 +259,51 @@ class Atom pack.reloadStylesheets?() null + # Public: + getCurrentWindow: -> + @constructor.getCurrentWindow() + + # Public: Get the dimensions of this window. + # + # Returns an object with x, y, width, and height keys. + getWindowDimensions: -> + browserWindow = @getCurrentWindow() + [x, y] = browserWindow.getPosition() + [width, height] = browserWindow.getSize() + {x, y, width, height} + + # Public: Set the dimensions of the window. + # + # The window will be centered if either the x or y coordinate is not set + # in the dimensions parameter. If x or y are omitted the window will be + # centered. If height or width are omitted only the position will be changed. + # + # * dimensions: + # + x: The new x coordinate. + # + y: The new y coordinate. + # + width: The new width. + # + height: The new height. + setWindowDimensions: ({x, y, width, height}) -> + browserWindow = @getCurrentWindow() + if width? and height? + browserWindow.setSize(width, height) + if x? and y? + browserWindow.setPosition(x, y) + else + browserWindow.center() + + # Private: + storeWindowDimensions: -> + @state.set('windowDimensions', @getWindowDimensions()) + + # Private: + restoreWindowDimensions: -> + windowDimensions = @state.getObject('windowDimensions') ? {} + {initialSize} = @getLoadSettings + windowDimensions.height ?= initialSize?.height ? global.screen.availHeight + windowDimensions.width ?= initialSize?.width ? Math.min(global.screen.availWidth, 1024) + @setWindowDimensions(windowDimensions) + # Public: Open a new Atom window using the given options. # # Calling this method without an options parameter will open a prompt to pick @@ -362,11 +427,11 @@ class Atom # Public: Get the version of the Atom application. getVersion: -> - app.getVersion() + @constructor.getVersion() # Public: Determine whether the current version is an official release. isReleasedVersion: -> - not /\w{7}/.test(@getVersion()) # Check if the release is a 7-character SHA prefix + @constructor.isReleasedVersion() getGitHubAuthTokenName: -> 'Atom GitHub API Token' @@ -383,87 +448,9 @@ class Atom # # Returns the absolute path to ~/.atom getConfigDirPath: -> + @constructor.getConfigDirPath() @configDirPath ?= fs.absolute('~/.atom') - # Public: Get the directory path to Atom's storage area. - # - # Returns the absoluste path to ~/.atom/storage - getStorageDirPath: -> - @storageDirPath ?= path.join(@getConfigDirPath(), 'storage') - - # Private: - getWindowStatePath: -> - switch @windowMode - when 'spec' - filename = @windowMode - when 'editor' - {initialPath} = @getLoadSettings() - if initialPath - sha1 = crypto.createHash('sha1').update(initialPath).digest('hex') - filename = "editor-#{sha1}" - - if filename - path.join(@getStorageDirPath(), filename) - else - null - - # Public: Set the window state of the given keypath to the value. - setWindowState: (keyPath, value) -> - windowState = @getWindowState() - windowState.set(keyPath, value) - windowState - - # Private - loadSerializedWindowState: -> - if windowStatePath = @getWindowStatePath() - if fs.existsSync(windowStatePath) - try - documentStateJson = fs.readFileSync(windowStatePath, 'utf8') - catch error - console.warn "Error reading window state: #{windowStatePath}", error.stack, error - else - documentStateJson = @getLoadSettings().windowState - - try - documentState = JSON.parse(documentStateJson) if documentStateJson - catch error - console.warn "Error parsing window state: #{windowStatePath}", error.stack, error - - # Private: - loadWindowState: -> - serializedWindowState = @loadSerializedWindowState() - doc = Document.deserialize(serializedWindowState) if serializedWindowState? - doc ?= Document.create() - doc.registerModelClasses( - require('./text-buffer'), - require('./project'), - require('./tokenized-buffer'), - require('./display-buffer'), - require('./editor') - ) - # TODO: Remove this when everything is using telepath models - if @site? - @site.setRootDocument(doc) - else - @site = new SiteShim(doc) - doc - - # Private: - saveWindowState: -> - windowState = @getWindowState() - if windowStatePath = @getWindowStatePath() - windowState.saveSync(windowStatePath) - else - @getCurrentWindow().loadSettings.windowState = JSON.stringify(windowState.serializeForPersistence()) - - # Public: Get the window state for the key path. - getWindowState: (keyPath) -> - @windowState ?= @loadWindowState() - if keyPath - @windowState.get(keyPath) - else - @windowState - # Public: Get the time taken to completely load the current window. # # This time include things like loading and activating packages, creating @@ -474,10 +461,6 @@ class Atom getWindowLoadTime: -> @loadTime - # Private: Returns a replicated copy of the current state. - replicate: -> - @getWindowState().replicate() - # Private: crashMainProcess: -> remote.process.crash() diff --git a/src/pane-axis.coffee b/src/pane-axis.coffee index 66c13b555..de872a1bc 100644 --- a/src/pane-axis.coffee +++ b/src/pane-axis.coffee @@ -15,7 +15,7 @@ class PaneAxis extends View @state.get('children').each (child, index) => @addChild(atom.deserializers.deserialize(child), index, updateState: false) else - @state = atom.site.createDocument(deserializer: @className(), children: []) + @state = atom.create(deserializer: @className(), children: []) @addChild(child) for child in args @state.get('children').on 'changed', ({index, insertedValues, removedValues, siteId}) => diff --git a/src/pane-container.coffee b/src/pane-container.coffee index ff9449b34..bdfde1818 100644 --- a/src/pane-container.coffee +++ b/src/pane-container.coffee @@ -23,7 +23,7 @@ class PaneContainer extends View @state = state @setRoot(atom.deserializers.deserialize(@state.get('root'))) else - @state = atom.site.createDocument(deserializer: 'PaneContainer') + @state = atom.create(deserializer: 'PaneContainer') @subscribe @state, 'changed', ({newValues, siteId}) => return if siteId is @state.siteId diff --git a/src/pane.coffee b/src/pane.coffee index fc784a85e..5fadee731 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -39,7 +39,7 @@ class Pane extends View item else @items = args - @state = atom.site.createDocument + @state = atom.create deserializer: 'Pane' items: @items.map (item) -> item.getState?() ? item.serialize() diff --git a/src/site-shim.coffee b/src/site-shim.coffee index 93b46feca..e4118f385 100644 --- a/src/site-shim.coffee +++ b/src/site-shim.coffee @@ -1,11 +1,8 @@ # Private: TODO remove once telepath upgrades are complete. module.exports = class SiteShim - constructor: (document) -> - @setRootDocument(document) - - setRootDocument: (@document) -> - @id = @document.siteId + constructor: (@environment) -> + {@id} = @environment.state.siteId createDocument: (values) -> - @document.create({values}) + @environment.create() diff --git a/src/window-bootstrap.coffee b/src/window-bootstrap.coffee index 052404487..dc8c46c42 100644 --- a/src/window-bootstrap.coffee +++ b/src/window-bootstrap.coffee @@ -7,8 +7,8 @@ require('crash-reporter').start(productName: 'Atom', companyName: 'GitHub') require './window' Atom = require './atom' -window.atom = new Atom() -atom.setUpEnvironment('editor') +window.atom = Atom.loadOrCreate('editor') +atom.initialize() atom.startEditorWindow() window.atom.loadTime = Date.now() - startTime console.log "Window load time: #{atom.getWindowLoadTime()}ms" diff --git a/src/window-event-handler.coffee b/src/window-event-handler.coffee index d21e46742..75ecc61ed 100644 --- a/src/window-event-handler.coffee +++ b/src/window-event-handler.coffee @@ -38,7 +38,7 @@ class WindowEventHandler confirmed @subscribe $(window), 'unload', -> - atom.getWindowState().set('dimensions', atom.getDimensions()) + atom.storeWindowDimensions() @subscribeToCommand $(window), 'window:toggle-full-screen', => atom.toggleFullScreen() diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index d56091dd9..4f2598fbf 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -70,7 +70,7 @@ class WorkspaceView extends View panes = atom.deserializers.deserialize(state.get('panes')) else panes = new PaneContainer - @state = atom.site.createDocument + @state = atom.create deserializer: @constructor.name version: @constructor.version panes: panes.getState() From 5f10c482196e34af9c53fb0a0ea1a763c486ba63 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 12 Dec 2013 14:40:12 -0800 Subject: [PATCH 02/23] Kill double project assignment --- spec/spec-helper.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 520d7b50b..49e1f8a88 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -49,7 +49,7 @@ if specDirectory beforeEach -> $.fx.off = true projectPath = specProjectPath ? path.join(@specDirectory, 'fixtures') - atom.project = atom.project = new Project(path: projectPath) + atom.project = new Project(path: projectPath) atom.keymap.keyBindings = _.clone(keyBindingsToRestore) window.resetTimeouts() From 30b0fed60fa0e4cc341dbdf0bf140a066594ec4b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 12 Dec 2013 15:11:59 -0800 Subject: [PATCH 03/23] Remove packageStates from atom state after specs just in case --- spec/spec-helper.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 49e1f8a88..10c226e5e 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -113,8 +113,7 @@ afterEach -> atom.project?.destroy?() atom.project = null - console.log atom.state.has('packageStates') - + atom.state.remove('packageStates') $('#jasmine-content').empty() unless window.debugContent From ebe77065ccb1b072b826b54420a28a012af8eb73 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 12 Dec 2013 15:12:16 -0800 Subject: [PATCH 04/23] Destroy orphans after each spec --- package.json | 2 +- spec/spec-helper.coffee | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 272d82bb9..2abd0a1cb 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "season": "0.14.0", "semver": "1.1.4", "space-pen": "2.0.1", - "telepath": "0.71.0", + "telepath": "0.72.0", "temp": "0.5.0", "underscore-plus": "0.5.0" }, diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 10c226e5e..8c66f6d76 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -116,6 +116,7 @@ afterEach -> atom.state.remove('packageStates') $('#jasmine-content').empty() unless window.debugContent + atom.destroyOrphans() jasmine.unspy(atom, 'saveSync') ensureNoPathSubscriptions() From 14c58c451759f5a117e22d5efaa5940d38176540 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 12 Dec 2013 15:12:51 -0800 Subject: [PATCH 05/23] Set up window event handler for all windows --- src/atom.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/atom.coffee b/src/atom.coffee index 79a3837f9..93d1bbd65 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -162,6 +162,7 @@ class Atom extends Model Editor = require './editor' @registerModelClasses(Project, TextBuffer, TokenizedBuffer, DisplayBuffer, Editor) + @windowEventHandler = new WindowEventHandler # Private: Call this method when establishing a real application window. startEditorWindow: -> @@ -170,7 +171,6 @@ class Atom extends Model CommandInstaller.installAtomCommand() CommandInstaller.installApmCommand() - @windowEventHandler = new WindowEventHandler @restoreWindowDimensions() @config.load() @config.setDefaults('core', require('./workspace-view').configDefaults) From a564cc66f6b97329a2c2a0bf98bc5231d5f4c850 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 12 Dec 2013 15:41:52 -0800 Subject: [PATCH 06/23] Replace Atom::getLoadSettings with a ::loadSettings property We assign a value into ::loadSettings anyway in a spec, so there's not much point leaving it a method. Eventually I'd like to pass all these settings in when constructing the Atom object and eliminate awareness of the loadSettings altogether from the Atom global. --- benchmark/benchmark-bootstrap.coffee | 2 +- benchmark/benchmark-helper.coffee | 2 +- spec/jasmine-helper.coffee | 2 +- spec/keymap-spec.coffee | 2 +- spec/spec-bootstrap.coffee | 4 ++-- spec/spec-helper.coffee | 2 +- spec/spec-suite.coffee | 4 ++-- spec/theme-manager-spec.coffee | 2 +- spec/window-spec.coffee | 1 - src/atom.coffee | 17 ++++++----------- src/command-installer.coffee | 4 ++-- 11 files changed, 18 insertions(+), 24 deletions(-) diff --git a/benchmark/benchmark-bootstrap.coffee b/benchmark/benchmark-bootstrap.coffee index 8d9a0ba4e..e6b4de693 100644 --- a/benchmark/benchmark-bootstrap.coffee +++ b/benchmark/benchmark-bootstrap.coffee @@ -1,7 +1,7 @@ require '../src/window' Atom = require '../src/atom' atom = new Atom() -atom.show() unless atom.getLoadSettings().exitWhenDone +atom.show() unless atom.loadSettings.exitWhenDone window.atom = atom {runSpecSuite} = require '../spec/jasmine-helper' diff --git a/benchmark/benchmark-helper.coffee b/benchmark/benchmark-helper.coffee index 312d2258d..bb7e329a5 100644 --- a/benchmark/benchmark-helper.coffee +++ b/benchmark/benchmark-helper.coffee @@ -40,7 +40,7 @@ window.benchmark = (args...) -> report = "#{fullname}: #{total} / #{count} = #{avg}ms" console.log(report) - if atom.getLoadSettings().exitWhenDone + if atom.loadSettings.exitWhenDone url = "https://github.com/_stats" data = [type: 'timing', metric: "atom.#{fullname}", ms: avg] $.ajax url, diff --git a/spec/jasmine-helper.coffee b/spec/jasmine-helper.coffee index 3d84e9d46..d279c35db 100644 --- a/spec/jasmine-helper.coffee +++ b/spec/jasmine-helper.coffee @@ -8,7 +8,7 @@ module.exports.runSpecSuite = (specSuite, logErrors=true) -> TimeReporter = require './time-reporter' timeReporter = new TimeReporter() - if atom.getLoadSettings().exitWhenDone + if atom.loadSettings.exitWhenDone {jasmineNode} = require 'jasmine-node/lib/jasmine-node/reporter' reporter = new jasmineNode.TerminalReporter print: (args...) -> diff --git a/spec/keymap-spec.coffee b/spec/keymap-spec.coffee index a74ede659..0749f0386 100644 --- a/spec/keymap-spec.coffee +++ b/spec/keymap-spec.coffee @@ -6,7 +6,7 @@ Keymap = require '../src/keymap' describe "Keymap", -> fragment = null keymap = null - resourcePath = atom.getLoadSettings().resourcePath + resourcePath = atom.loadSettings.resourcePath beforeEach -> keymap = new Keymap({configDirPath: atom.getConfigDirPath(), resourcePath}) diff --git a/spec/spec-bootstrap.coffee b/spec/spec-bootstrap.coffee index 8e877ce04..0ef64457e 100644 --- a/spec/spec-bootstrap.coffee +++ b/spec/spec-bootstrap.coffee @@ -5,13 +5,13 @@ try require '../src/window' Atom = require '../src/atom' window.atom = Atom.loadOrCreate('spec') - window.atom.show() unless atom.getLoadSettings().exitWhenDone + window.atom.show() unless atom.loadSettings.exitWhenDone {runSpecSuite} = require './jasmine-helper' document.title = "Spec Suite" runSpecSuite './spec-suite' catch error - if atom?.getLoadSettings().exitWhenDone + if atom?.loadSettings.exitWhenDone console.error(error.stack ? error) atom.exit(1) else diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 8c66f6d76..629c99890 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -38,7 +38,7 @@ specPackageName = null specPackagePath = null specProjectPath = null -{specDirectory, resourcePath} = atom.getLoadSettings() +{specDirectory, resourcePath} = atom.loadSettings if specDirectory specPackagePath = path.resolve(specDirectory, '..') diff --git a/spec/spec-suite.coffee b/spec/spec-suite.coffee index 6beade358..1d345222d 100644 --- a/spec/spec-suite.coffee +++ b/spec/spec-suite.coffee @@ -23,7 +23,7 @@ setSpecDirectory = (specDirectory) -> setSpecField('specDirectory', specDirectory) runAllSpecs = -> - {resourcePath} = atom.getLoadSettings() + {resourcePath} = atom.loadSettings # Only run core specs when resource path is the Atom repository if Git.exists(resourcePath) requireSpecs(path.join(resourcePath, 'spec')) @@ -48,7 +48,7 @@ runAllSpecs = -> requireSpecs(path.join(packagePath, 'spec')) for packagePath in packagePaths.user ? [] setSpecType('user') -if specDirectory = atom.getLoadSettings().specDirectory +if specDirectory = atom.loadSettings.specDirectory requireSpecs(specDirectory) setSpecType('user') else diff --git a/spec/theme-manager-spec.coffee b/spec/theme-manager-spec.coffee index bb96a5b2a..ba2d76661 100644 --- a/spec/theme-manager-spec.coffee +++ b/spec/theme-manager-spec.coffee @@ -6,7 +6,7 @@ AtomPackage = require '../src/atom-package' describe "ThemeManager", -> themeManager = null - resourcePath = atom.getLoadSettings().resourcePath + resourcePath = atom.loadSettings.resourcePath configDirPath = atom.getConfigDirPath() beforeEach -> diff --git a/spec/window-spec.coffee b/spec/window-spec.coffee index 68f9adeb2..f98bb2f2d 100644 --- a/spec/window-spec.coffee +++ b/spec/window-spec.coffee @@ -7,7 +7,6 @@ describe "Window", -> beforeEach -> spyOn(atom, 'hide') - atom.getLoadSettings() # Causes atom.loadSettings to be initialized atom.loadSettings.initialPath = atom.project.getPath() atom.project.destroy() windowEventHandler = new WindowEventHandler() diff --git a/src/atom.coffee b/src/atom.coffee index 93d1bbd65..25431755c 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -122,6 +122,7 @@ class Atom extends Model created: -> DeserializerManager = require './deserializer-manager' @deserializers = new DeserializerManager() + @loadSettings = @constructor.getLoadSettings() # Public: Sets up the basic services that should be available in all modes # (both spec and application). Call after this instance has been assigned to @@ -140,7 +141,7 @@ class Atom extends Model ThemeManager = require './theme-manager' ContextMenuManager = require './context-menu-manager' MenuManager = require './menu-manager' - {devMode, resourcePath} = @getLoadSettings() + {devMode, resourcePath} = @loadSettings configDirPath = @getConfigDirPath() @config = new Config({configDirPath, resourcePath}) @@ -202,16 +203,10 @@ class Atom extends Model setBodyPlatformClass: -> document.body.classList.add("platform-#{process.platform}") - # Public: Get the load settings for the current window. - # - # Returns an object containing all the load setting key/value pairs. - getLoadSettings: -> - @constructor.getLoadSettings() - # Private: deserializeProject: -> Project = require './project' - @project ?= new Project(path: @getLoadSettings().initialPath) + @project ?= new Project(path: @loadSettings.initialPath) # Private: deserializeWorkspaceView: -> @@ -299,7 +294,7 @@ class Atom extends Model # Private: restoreWindowDimensions: -> windowDimensions = @state.getObject('windowDimensions') ? {} - {initialSize} = @getLoadSettings + {initialSize} = @loadSettings windowDimensions.height ?= initialSize?.height ? global.screen.availHeight windowDimensions.width ?= initialSize?.width ? Math.min(global.screen.availWidth, 1024) @setWindowDimensions(windowDimensions) @@ -407,11 +402,11 @@ class Atom extends Model # Public: Is the current window in development mode? inDevMode: -> - @getLoadSettings().devMode + @loadSettings.devMode # Public: Is the current window running specs? inSpecMode: -> - @getLoadSettings().isSpec + @loadSettings.isSpec # Public: Toggle the full screen state of the current window. toggleFullScreen: -> diff --git a/src/command-installer.coffee b/src/command-installer.coffee index b1515d46f..634b11c4b 100644 --- a/src/command-installer.coffee +++ b/src/command-installer.coffee @@ -54,7 +54,7 @@ module.exports = callback = resourcePath resourcePath = null - resourcePath ?= atom.getLoadSettings().resourcePath + resourcePath ?= atom.loadSettings.resourcePath commandPath = path.join(resourcePath, 'atom.sh') @install(commandPath, callback) @@ -63,6 +63,6 @@ module.exports = callback = resourcePath resourcePath = null - resourcePath ?= atom.getLoadSettings().resourcePath + resourcePath ?= atom.loadSettings.resourcePath commandPath = path.join(resourcePath, 'node_modules', '.bin', 'apm') @install(commandPath, callback) From 4c817baf4c948703c65316b848a912d41aebf34e Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 12 Dec 2013 16:34:10 -0800 Subject: [PATCH 07/23] Don't destroy project when WorkspaceView is removed Whenever we're removing the workspaceView, we're usually destroying the project anyway. --- src/workspace-view.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 4f2598fbf..ad2022b04 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -317,7 +317,6 @@ class WorkspaceView extends View # Private: Destroys everything. remove: -> editorView.remove() for editorView in @getEditorViews() - atom.project?.destroy() super # Private: Adds the destroyed item's uri to the list of items to reopen. From a61b057aeaae4e22cecf09be87dac0705253335a Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 12 Dec 2013 16:34:48 -0800 Subject: [PATCH 08/23] Eliminate exceptions in Editor::inspect --- src/editor.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editor.coffee b/src/editor.coffee index b317d2c7a..cba3382fd 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -1400,7 +1400,7 @@ class Editor extends Model # Private: inspect: -> - JSON.stringify @state.toObject() + "" # Private: logScreenLines: (start, end) -> @displayBuffer.logLines(start, end) From 0b7f291e176cf65d336340e4a31dddb9a00315db Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 12 Dec 2013 16:35:26 -0800 Subject: [PATCH 09/23] Remove reference to workspaceView in Atom::unloadEditorWindow --- src/atom.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/atom.coffee b/src/atom.coffee index 25431755c..c93a4d363 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -238,6 +238,7 @@ class Atom extends Model @state.set('packageStates', @packages.packageStates) @saveSync() @workspaceView.remove() + @workspaceView = null @project.destroy() @windowEventHandler?.unsubscribe() @windowState = null From 208ed09109e80866d1645bc4c115540eb2d9c20e Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 12 Dec 2013 16:35:56 -0800 Subject: [PATCH 10/23] Use atom.state instead of defunct windowState in spec --- spec/window-spec.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/window-spec.coffee b/spec/window-spec.coffee index f98bb2f2d..8d0d68fce 100644 --- a/spec/window-spec.coffee +++ b/spec/window-spec.coffee @@ -87,9 +87,9 @@ describe "Window", -> atom.unloadEditorWindow() - expect(atom.getWindowState().getObject('workspaceView')).toEqual workspaceViewState.toObject() - expect(atom.getWindowState().getObject('syntax')).toEqual syntaxState - expect(atom.saveWindowState).toHaveBeenCalled() + expect(atom.state.getObject('workspaceView')).toEqual workspaceViewState.toObject() + expect(atom.state.getObject('syntax')).toEqual syntaxState + expect(atom.saveSync).toHaveBeenCalled() it "unsubscribes from all buffers", -> atom.workspaceView.openSync('sample.js') From bfcb24f51772f54d9c1c8010bdc58ab0d49caa8c Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 12 Dec 2013 16:36:34 -0800 Subject: [PATCH 11/23] Fix pesky workspace view serialization spec This isn't beautiful, but this whole approach is slated to be replaced in the recent future. --- spec/workspace-view-spec.coffee | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spec/workspace-view-spec.coffee b/spec/workspace-view-spec.coffee index a8449cc76..2a0930e9b 100644 --- a/spec/workspace-view-spec.coffee +++ b/spec/workspace-view-spec.coffee @@ -19,8 +19,10 @@ describe "WorkspaceView", -> viewState = null simulateReload = -> - atom.unloadEditorWindow() - atom.deserializeEditorWindow() + state = atom.workspaceView.serialize().replicate() + atom.workspaceView.remove() + atom.workspaceView = WorkspaceView.deserialize(state) + atom.workspaceView.attachToDom() describe "when the serialized WorkspaceView has an unsaved buffer", -> it "constructs the view with the same panes", -> @@ -29,12 +31,12 @@ describe "WorkspaceView", -> editor1 = atom.workspaceView.getActiveView() buffer = editor1.getBuffer() editor1.splitRight() - expect(atom.workspaceView.getActiveView()).toBe atom.workspaceView.getEditorViews()[2] + expect(atom.workspaceView.getActivePane()).toBe atom.workspaceView.getPanes()[1] simulateReload() expect(atom.workspaceView.getEditorViews().length).toBe 2 - expect(atom.workspaceView.getActiveView()).toBe atom.workspaceView.getEditorViews()[1] + expect(atom.workspaceView.getActivePane()).toBe atom.workspaceView.getPanes()[1] expect(atom.workspaceView.title).toBe "untitled - #{atom.project.getPath()}" describe "when there are open editors", -> From 39fe0c418b40587894355a3be6770d7694c42d80 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 12 Dec 2013 16:49:00 -0800 Subject: [PATCH 12/23] Add back deprecated Atom::getLoadSettings method for packages --- src/atom.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/atom.coffee b/src/atom.coffee index c93a4d363..538dea1bd 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -165,6 +165,11 @@ class Atom extends Model @windowEventHandler = new WindowEventHandler + # Deprecated: Just access the loadSettings property directly. Eventually I want + # both to go away and just store the relevant info on the atom global itself. + getLoadSettings: -> + @loadSettings + # Private: Call this method when establishing a real application window. startEditorWindow: -> if process.platform is 'darwin' From 165a417a9da5a094f8547414daf7eec27281b40e Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 12 Dec 2013 16:59:41 -0800 Subject: [PATCH 13/23] Upgrade to telepath 0.73.0 for Document::create default values --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2abd0a1cb..a4a860c37 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "season": "0.14.0", "semver": "1.1.4", "space-pen": "2.0.1", - "telepath": "0.72.0", + "telepath": "0.73.0", "temp": "0.5.0", "underscore-plus": "0.5.0" }, From 24d3f1daeb0c2d332bd24f768351973ae2b8e317 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 13 Dec 2013 09:50:57 -0800 Subject: [PATCH 14/23] Reduce diff size by restoring old method order where possible --- src/atom.coffee | 192 ++++++++++++++++++++++++------------------------ 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/src/atom.coffee b/src/atom.coffee index 3c99098a6..c1f1e80e0 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -165,101 +165,10 @@ class Atom extends Model @windowEventHandler = new WindowEventHandler - # Deprecated: Just access the loadSettings property directly. Eventually I want - # both to go away and just store the relevant info on the atom global itself. - getLoadSettings: -> - @loadSettings - - # Private: Call this method when establishing a real application window. - startEditorWindow: -> - if process.platform is 'darwin' - CommandInstaller = require './command-installer' - CommandInstaller.installAtomCommand() - CommandInstaller.installApmCommand() - - @restoreWindowDimensions() - @config.load() - @config.setDefaults('core', require('./workspace-view').configDefaults) - @config.setDefaults('editor', require('./editor-view').configDefaults) - @keymap.loadBundledKeymaps() - @themes.loadBaseStylesheets() - @packages.loadPackages() - @deserializeEditorWindow() - @packages.activate() - @keymap.loadUserKeymap() - @requireUserInitScript() - @menu.update() - - $(window).on 'unload', => - $(document.body).css('visibility', 'hidden') - @unloadEditorWindow() - false - - @displayWindow() - - # Private: - saveSync: -> - if statePath = @constructor.getStatePath(@mode) - super(statePath) - else - @getCurrentWindow().loadSettings.windowState = JSON.stringify(@serializeForPersistence()) - # Private: setBodyPlatformClass: -> document.body.classList.add("platform-#{process.platform}") - # Private: - deserializeProject: -> - Project = require './project' - @project ?= new Project(path: @loadSettings.initialPath) - - # Private: - deserializeWorkspaceView: -> - WorkspaceView = require './workspace-view' - @workspaceView = @deserializers.deserialize(@state.get('workspaceView')) - unless @workspaceView? - @workspaceView = new WorkspaceView() - @state.set('workspaceView', @workspaceView.getState()) - $(@workspaceViewParentSelector).append(@workspaceView) - - # Private: - deserializePackageStates: -> - @packages.packageStates = @state.getObject('packageStates') ? {} - @state.remove('packageStates') - - # Private: - deserializeEditorWindow: -> - @deserializePackageStates() - @deserializeProject() - @deserializeWorkspaceView() - - # Private: - unloadEditorWindow: -> - return if not @project and not @workspaceView - - @state.set('syntax', @syntax.serialize()) - @state.set('workspaceView', @workspaceView.serialize()) - @packages.deactivatePackages() - @state.set('packageStates', @packages.packageStates) - @saveSync() - @workspaceView.remove() - @workspaceView = null - @project.destroy() - @windowEventHandler?.unsubscribe() - @windowState = null - - # Private: - loadThemes: -> - @themes.load() - - # Private: - watchThemes: -> - @themes.on 'reloaded', => - # Only reload stylesheets from non-theme packages - for pack in @packages.getActivePackages() when pack.getType() isnt 'theme' - pack.reloadStylesheets?() - null - # Public: getCurrentWindow: -> @constructor.getCurrentWindow() @@ -293,10 +202,6 @@ class Atom extends Model else browserWindow.center() - # Private: - storeWindowDimensions: -> - @state.set('windowDimensions', @getWindowDimensions()) - # Private: restoreWindowDimensions: -> windowDimensions = @state.getObject('windowDimensions') ? {} @@ -305,6 +210,94 @@ class Atom extends Model windowDimensions.width ?= initialSize?.width ? Math.min(global.screen.availWidth, 1024) @setWindowDimensions(windowDimensions) + # Private: + storeWindowDimensions: -> + @state.set('windowDimensions', @getWindowDimensions()) + + # Deprecated: Just access the loadSettings property directly. Eventually I want + # both to go away and just store the relevant info on the atom global itself. + getLoadSettings: -> + @loadSettings + + # Private: + deserializeProject: -> + Project = require './project' + @project ?= new Project(path: @loadSettings.initialPath) + + # Private: + deserializeWorkspaceView: -> + WorkspaceView = require './workspace-view' + @workspaceView = @deserializers.deserialize(@state.get('workspaceView')) + unless @workspaceView? + @workspaceView = new WorkspaceView() + @state.set('workspaceView', @workspaceView.getState()) + $(@workspaceViewParentSelector).append(@workspaceView) + + # Private: + deserializePackageStates: -> + @packages.packageStates = @state.getObject('packageStates') ? {} + @state.remove('packageStates') + + # Private: + deserializeEditorWindow: -> + @deserializePackageStates() + @deserializeProject() + @deserializeWorkspaceView() + + # Private: Call this method when establishing a real application window. + startEditorWindow: -> + if process.platform is 'darwin' + CommandInstaller = require './command-installer' + CommandInstaller.installAtomCommand() + CommandInstaller.installApmCommand() + + @restoreWindowDimensions() + @config.load() + @config.setDefaults('core', require('./workspace-view').configDefaults) + @config.setDefaults('editor', require('./editor-view').configDefaults) + @keymap.loadBundledKeymaps() + @themes.loadBaseStylesheets() + @packages.loadPackages() + @deserializeEditorWindow() + @packages.activate() + @keymap.loadUserKeymap() + @requireUserInitScript() + @menu.update() + + $(window).on 'unload', => + $(document.body).css('visibility', 'hidden') + @unloadEditorWindow() + false + + @displayWindow() + + # Private: + unloadEditorWindow: -> + return if not @project and not @workspaceView + + @state.set('syntax', @syntax.serialize()) + @state.set('workspaceView', @workspaceView.serialize()) + @packages.deactivatePackages() + @state.set('packageStates', @packages.packageStates) + @saveSync() + @workspaceView.remove() + @workspaceView = null + @project.destroy() + @windowEventHandler?.unsubscribe() + @windowState = null + + # Private: + loadThemes: -> + @themes.load() + + # Private: + watchThemes: -> + @themes.on 'reloaded', => + # Only reload stylesheets from non-theme packages + for pack in @packages.getActivePackages() when pack.getType() isnt 'theme' + pack.reloadStylesheets?() + null + # Public: Open a new Atom window using the given options. # # Calling this method without an options parameter will open a prompt to pick @@ -450,7 +443,14 @@ class Atom extends Model # Returns the absolute path to ~/.atom getConfigDirPath: -> @constructor.getConfigDirPath() - @configDirPath ?= fs.absolute('~/.atom') + + # Private: + saveSync: -> + if statePath = @constructor.getStatePath(@mode) + super(statePath) + else + @getCurrentWindow().loadSettings.windowState = JSON.stringify(@serializeForPersistence()) + # Public: Get the time taken to completely load the current window. # From 2c4aee1181dbb4033c13a3200e156e5505b0886d Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 13 Dec 2013 09:55:13 -0800 Subject: [PATCH 15/23] Restore cloning of ::loadSettings in ::getLoadSettings It's a deprecated method, but if you call it you'll get a clone. --- src/atom.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/atom.coffee b/src/atom.coffee index c1f1e80e0..d0de3c02a 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -217,7 +217,7 @@ class Atom extends Model # Deprecated: Just access the loadSettings property directly. Eventually I want # both to go away and just store the relevant info on the atom global itself. getLoadSettings: -> - @loadSettings + _.deepClone(@loadSettings) # Private: deserializeProject: -> From da964a8f15fba631b0cfd953e48034fabe0e8988 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 13 Dec 2013 09:55:45 -0800 Subject: [PATCH 16/23] Fix comment --- src/atom.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/atom.coffee b/src/atom.coffee index d0de3c02a..744a91fd7 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -214,8 +214,8 @@ class Atom extends Model storeWindowDimensions: -> @state.set('windowDimensions', @getWindowDimensions()) - # Deprecated: Just access the loadSettings property directly. Eventually I want - # both to go away and just store the relevant info on the atom global itself. + # Deprecated: Just access the loadSettings property directly. We should just pass + # these properties into the object itself when constructing it. getLoadSettings: -> _.deepClone(@loadSettings) From e18a0f045ad09100f94aa6ef2eb987274438b323 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 13 Dec 2013 11:02:03 -0800 Subject: [PATCH 17/23] Upgrade to telepath 0.74.0 to avoid shredding of orphaned object graphs We call atom.destroyOrphans after each spec now to clean up any orphaned objects. Previously, we we destroying any object not reachable from the root document. This was causing children of orphaned objects to be removed from their parent, which caused null pointer exceptions when running the destroy handlers for the orphans. Now we only destroy the roots of orphaned object graphs. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 36af98666..e7825effd 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "season": "0.14.0", "semver": "1.1.4", "space-pen": "2.0.2", - "telepath": "0.73.0", + "telepath": "0.74.0", "temp": "0.5.0", "underscore-plus": "0.5.0" }, From e67e8ff0f535984fd7c16cf01476abc7b4133b70 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 13 Dec 2013 12:02:48 -0800 Subject: [PATCH 18/23] Restore Atom::getLoadSettings and spy on it in window spec I initially ripped out Atom::getLoadSettings in favor of a mutable property because window spec was making an assumption that such a property existed anyway. Since load settings need to be available from class methods, the instance method just delegates to the class method. But that means there's no ::loadSettings property to mutate in that spec. I replaced the former approach with a spy which has the added advantage of not polluting windowSettings for subsequent specs. --- benchmark/benchmark-bootstrap.coffee | 2 +- benchmark/benchmark-helper.coffee | 2 +- spec/jasmine-helper.coffee | 2 +- spec/keymap-spec.coffee | 2 +- spec/spec-bootstrap.coffee | 4 ++-- spec/spec-helper.coffee | 2 +- spec/spec-suite.coffee | 4 ++-- spec/theme-manager-spec.coffee | 2 +- spec/window-spec.coffee | 6 +++++- src/atom.coffee | 18 +++++++++--------- src/command-installer.coffee | 4 ++-- 11 files changed, 26 insertions(+), 22 deletions(-) diff --git a/benchmark/benchmark-bootstrap.coffee b/benchmark/benchmark-bootstrap.coffee index e6b4de693..8d9a0ba4e 100644 --- a/benchmark/benchmark-bootstrap.coffee +++ b/benchmark/benchmark-bootstrap.coffee @@ -1,7 +1,7 @@ require '../src/window' Atom = require '../src/atom' atom = new Atom() -atom.show() unless atom.loadSettings.exitWhenDone +atom.show() unless atom.getLoadSettings().exitWhenDone window.atom = atom {runSpecSuite} = require '../spec/jasmine-helper' diff --git a/benchmark/benchmark-helper.coffee b/benchmark/benchmark-helper.coffee index bb7e329a5..312d2258d 100644 --- a/benchmark/benchmark-helper.coffee +++ b/benchmark/benchmark-helper.coffee @@ -40,7 +40,7 @@ window.benchmark = (args...) -> report = "#{fullname}: #{total} / #{count} = #{avg}ms" console.log(report) - if atom.loadSettings.exitWhenDone + if atom.getLoadSettings().exitWhenDone url = "https://github.com/_stats" data = [type: 'timing', metric: "atom.#{fullname}", ms: avg] $.ajax url, diff --git a/spec/jasmine-helper.coffee b/spec/jasmine-helper.coffee index d279c35db..3d84e9d46 100644 --- a/spec/jasmine-helper.coffee +++ b/spec/jasmine-helper.coffee @@ -8,7 +8,7 @@ module.exports.runSpecSuite = (specSuite, logErrors=true) -> TimeReporter = require './time-reporter' timeReporter = new TimeReporter() - if atom.loadSettings.exitWhenDone + if atom.getLoadSettings().exitWhenDone {jasmineNode} = require 'jasmine-node/lib/jasmine-node/reporter' reporter = new jasmineNode.TerminalReporter print: (args...) -> diff --git a/spec/keymap-spec.coffee b/spec/keymap-spec.coffee index 0749f0386..a74ede659 100644 --- a/spec/keymap-spec.coffee +++ b/spec/keymap-spec.coffee @@ -6,7 +6,7 @@ Keymap = require '../src/keymap' describe "Keymap", -> fragment = null keymap = null - resourcePath = atom.loadSettings.resourcePath + resourcePath = atom.getLoadSettings().resourcePath beforeEach -> keymap = new Keymap({configDirPath: atom.getConfigDirPath(), resourcePath}) diff --git a/spec/spec-bootstrap.coffee b/spec/spec-bootstrap.coffee index 0ef64457e..8e877ce04 100644 --- a/spec/spec-bootstrap.coffee +++ b/spec/spec-bootstrap.coffee @@ -5,13 +5,13 @@ try require '../src/window' Atom = require '../src/atom' window.atom = Atom.loadOrCreate('spec') - window.atom.show() unless atom.loadSettings.exitWhenDone + window.atom.show() unless atom.getLoadSettings().exitWhenDone {runSpecSuite} = require './jasmine-helper' document.title = "Spec Suite" runSpecSuite './spec-suite' catch error - if atom?.loadSettings.exitWhenDone + if atom?.getLoadSettings().exitWhenDone console.error(error.stack ? error) atom.exit(1) else diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 1bd3b9e1c..618f81503 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -39,7 +39,7 @@ specPackageName = null specPackagePath = null specProjectPath = null -{specDirectory, resourcePath} = atom.loadSettings +{specDirectory, resourcePath} = atom.getLoadSettings() if specDirectory specPackagePath = path.resolve(specDirectory, '..') diff --git a/spec/spec-suite.coffee b/spec/spec-suite.coffee index 1d345222d..6beade358 100644 --- a/spec/spec-suite.coffee +++ b/spec/spec-suite.coffee @@ -23,7 +23,7 @@ setSpecDirectory = (specDirectory) -> setSpecField('specDirectory', specDirectory) runAllSpecs = -> - {resourcePath} = atom.loadSettings + {resourcePath} = atom.getLoadSettings() # Only run core specs when resource path is the Atom repository if Git.exists(resourcePath) requireSpecs(path.join(resourcePath, 'spec')) @@ -48,7 +48,7 @@ runAllSpecs = -> requireSpecs(path.join(packagePath, 'spec')) for packagePath in packagePaths.user ? [] setSpecType('user') -if specDirectory = atom.loadSettings.specDirectory +if specDirectory = atom.getLoadSettings().specDirectory requireSpecs(specDirectory) setSpecType('user') else diff --git a/spec/theme-manager-spec.coffee b/spec/theme-manager-spec.coffee index ba2d76661..bb96a5b2a 100644 --- a/spec/theme-manager-spec.coffee +++ b/spec/theme-manager-spec.coffee @@ -6,7 +6,7 @@ AtomPackage = require '../src/atom-package' describe "ThemeManager", -> themeManager = null - resourcePath = atom.loadSettings.resourcePath + resourcePath = atom.getLoadSettings().resourcePath configDirPath = atom.getConfigDirPath() beforeEach -> diff --git a/spec/window-spec.coffee b/spec/window-spec.coffee index 2b6f1a6fb..de01bf375 100644 --- a/spec/window-spec.coffee +++ b/spec/window-spec.coffee @@ -8,7 +8,11 @@ describe "Window", -> beforeEach -> spyOn(atom, 'hide') - atom.loadSettings.initialPath = atom.project.getPath() + initialPath = atom.project.getPath() + spyOn(atom, 'getLoadSettings').andCallFake -> + loadSettings = atom.getLoadSettings.originalValue.call(atom) + loadSettings.initialPath = initialPath + loadSettings atom.project.destroy() windowEventHandler = new WindowEventHandler() atom.deserializeEditorWindow() diff --git a/src/atom.coffee b/src/atom.coffee index 744a91fd7..5fd1baf3d 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -122,7 +122,6 @@ class Atom extends Model created: -> DeserializerManager = require './deserializer-manager' @deserializers = new DeserializerManager() - @loadSettings = @constructor.getLoadSettings() # Public: Sets up the basic services that should be available in all modes # (both spec and application). Call after this instance has been assigned to @@ -141,7 +140,7 @@ class Atom extends Model ThemeManager = require './theme-manager' ContextMenuManager = require './context-menu-manager' MenuManager = require './menu-manager' - {devMode, resourcePath} = @loadSettings + {devMode, resourcePath} = @getLoadSettings() configDirPath = @getConfigDirPath() @config = new Config({configDirPath, resourcePath}) @@ -205,7 +204,7 @@ class Atom extends Model # Private: restoreWindowDimensions: -> windowDimensions = @state.getObject('windowDimensions') ? {} - {initialSize} = @loadSettings + {initialSize} = @getLoadSettings() windowDimensions.height ?= initialSize?.height ? global.screen.availHeight windowDimensions.width ?= initialSize?.width ? Math.min(global.screen.availWidth, 1024) @setWindowDimensions(windowDimensions) @@ -214,15 +213,16 @@ class Atom extends Model storeWindowDimensions: -> @state.set('windowDimensions', @getWindowDimensions()) - # Deprecated: Just access the loadSettings property directly. We should just pass - # these properties into the object itself when constructing it. + # Public: Get the load settings for the current window. + # + # Returns an object containing all the load setting key/value pairs. getLoadSettings: -> - _.deepClone(@loadSettings) + @constructor.getLoadSettings() # Private: deserializeProject: -> Project = require './project' - @project ?= new Project(path: @loadSettings.initialPath) + @project ?= new Project(path: @getLoadSettings().initialPath) # Private: deserializeWorkspaceView: -> @@ -401,11 +401,11 @@ class Atom extends Model # Public: Is the current window in development mode? inDevMode: -> - @loadSettings.devMode + @getLoadSettings().devMode # Public: Is the current window running specs? inSpecMode: -> - @loadSettings.isSpec + @getLoadSettings().isSpec # Public: Toggle the full screen state of the current window. toggleFullScreen: -> diff --git a/src/command-installer.coffee b/src/command-installer.coffee index 634b11c4b..b1515d46f 100644 --- a/src/command-installer.coffee +++ b/src/command-installer.coffee @@ -54,7 +54,7 @@ module.exports = callback = resourcePath resourcePath = null - resourcePath ?= atom.loadSettings.resourcePath + resourcePath ?= atom.getLoadSettings().resourcePath commandPath = path.join(resourcePath, 'atom.sh') @install(commandPath, callback) @@ -63,6 +63,6 @@ module.exports = callback = resourcePath resourcePath = null - resourcePath ?= atom.loadSettings.resourcePath + resourcePath ?= atom.getLoadSettings().resourcePath commandPath = path.join(resourcePath, 'node_modules', '.bin', 'apm') @install(commandPath, callback) From ed41cc3cad25be436675569149b9bfa948d1c2f0 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 13 Dec 2013 14:07:30 -0800 Subject: [PATCH 19/23] Restore comment --- src/atom.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/atom.coffee b/src/atom.coffee index 5fd1baf3d..c92ddb4e5 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -168,7 +168,7 @@ class Atom extends Model setBodyPlatformClass: -> document.body.classList.add("platform-#{process.platform}") - # Public: + # Public: Get the current window getCurrentWindow: -> @constructor.getCurrentWindow() From 3db9e166375b5759ef2f01da2b576ed690b230c8 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 16 Dec 2013 19:03:10 -0700 Subject: [PATCH 20/23] Upgrade to telepath 0.75.0 for custom object support --- exports/atom.coffee | 5 +++-- package.json | 2 +- src/atom.coffee | 4 ++-- src/deserializer-manager.coffee | 4 ++-- src/pane-axis.coffee | 4 ++-- src/pane-container.coffee | 4 ++-- src/pane.coffee | 4 ++-- src/project.coffee | 2 +- src/text-buffer.coffee | 2 +- src/workspace-view.coffee | 4 ++-- 10 files changed, 18 insertions(+), 17 deletions(-) diff --git a/exports/atom.coffee b/exports/atom.coffee index 35a65c566..1b1927737 100644 --- a/exports/atom.coffee +++ b/exports/atom.coffee @@ -1,11 +1,12 @@ -{Document, Model, Point, Range} = require 'telepath' +{TelepathicObject, Model, Point, Range} = require 'telepath' module.exports = _: require 'underscore-plus' BufferedNodeProcess: require '../src/buffered-node-process' BufferedProcess: require '../src/buffered-process' Directory: require '../src/directory' - Document: Document + TelepathicObject: TelepathicObject + Document: TelepathicObject # Deprecated Shim File: require '../src/file' fs: require 'fs-plus' Git: require '../src/git' diff --git a/package.json b/package.json index 601b8d5e6..e28c068e5 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "season": "0.14.0", "semver": "1.1.4", "space-pen": "2.0.2", - "telepath": "0.74.0", + "telepath": "0.75.0", "temp": "0.5.0", "underscore-plus": "0.5.0" }, diff --git a/src/atom.coffee b/src/atom.coffee index e5eb9b839..fc68aa5fb 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -10,7 +10,7 @@ app = remote.require 'app' _ = require 'underscore-plus' telepath = require 'telepath' -{Document, Model} = telepath +{Model} = telepath fs = require 'fs-plus' {$} = require './space-pen-extensions' @@ -160,7 +160,7 @@ class Atom extends Model TokenizedBuffer = require './tokenized-buffer' DisplayBuffer = require './display-buffer' Editor = require './editor' - @registerModelClasses(Project, TextBuffer, TokenizedBuffer, DisplayBuffer, Editor) + @registerRepresentationClasses(Project, TextBuffer, TokenizedBuffer, DisplayBuffer, Editor) @windowEventHandler = new WindowEventHandler diff --git a/src/deserializer-manager.coffee b/src/deserializer-manager.coffee index 4f6b51588..bf3e77bb6 100644 --- a/src/deserializer-manager.coffee +++ b/src/deserializer-manager.coffee @@ -1,4 +1,4 @@ -{Document, Model} = require 'telepath' +{TelepathicObject, Model} = require 'telepath' # Public: Manages the deserializers used for serialized state # @@ -30,7 +30,7 @@ class DeserializerManager if deserializer = @get(state) stateVersion = state.get?('version') ? state.version return if deserializer.version? and deserializer.version isnt stateVersion - if (state instanceof Document) and not deserializer.acceptsDocuments + if (state instanceof TelepathicObject) and not deserializer.acceptsDocuments state = state.toObject() deserializer.deserialize(state, params) else diff --git a/src/pane-axis.coffee b/src/pane-axis.coffee index de872a1bc..f8ed436a3 100644 --- a/src/pane-axis.coffee +++ b/src/pane-axis.coffee @@ -1,5 +1,5 @@ {$, View} = require './space-pen-extensions' -telepath = require 'telepath' +{TelepathicObject} = require 'telepath' ### Internal ### module.exports = @@ -10,7 +10,7 @@ class PaneAxis extends View new this(state) initialize: (args...) -> - if args[0] instanceof telepath.Document + if args[0] instanceof TelepathicObject @state = args[0] @state.get('children').each (child, index) => @addChild(atom.deserializers.deserialize(child), index, updateState: false) diff --git a/src/pane-container.coffee b/src/pane-container.coffee index bdfde1818..97818aef7 100644 --- a/src/pane-container.coffee +++ b/src/pane-container.coffee @@ -1,6 +1,6 @@ {$, View} = require './space-pen-extensions' Pane = require './pane' -telepath = require 'telepath' +{TelepathicObject} = require 'telepath' # Private: Manages the list of panes within a {WorkspaceView} module.exports = @@ -19,7 +19,7 @@ class PaneContainer extends View @div class: 'panes' initialize: (state) -> - if state instanceof telepath.Document + if state instanceof TelepathicObject @state = state @setRoot(atom.deserializers.deserialize(@state.get('root'))) else diff --git a/src/pane.coffee b/src/pane.coffee index 440041f8a..72c69f8c4 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -1,7 +1,7 @@ {dirname} = require 'path' {$, View} = require './space-pen-extensions' _ = require 'underscore-plus' -telepath = require 'telepath' +{TelepathicObject} = require 'telepath' PaneRow = require './pane-row' PaneColumn = require './pane-column' @@ -32,7 +32,7 @@ class Pane extends View # Private: initialize: (args...) -> @items = [] - if args[0] instanceof telepath.Document + if args[0] instanceof TelepathicObject @state = args[0] @items = _.compact @state.get('items').map (item) -> item = atom.deserializers.deserialize(item) diff --git a/src/project.coffee b/src/project.coffee index eae064fd6..a5eb712db 100644 --- a/src/project.coffee +++ b/src/project.coffee @@ -39,7 +39,7 @@ class Project extends Model @setPath(@path) # Private: Called by telepath. - beforePersistence: -> + willBePersisted: -> @destroyUnretainedBuffers() # Public: Register an opener for project files. diff --git a/src/text-buffer.coffee b/src/text-buffer.coffee index b5936c8fb..8ea770bcc 100644 --- a/src/text-buffer.coffee +++ b/src/text-buffer.coffee @@ -48,7 +48,7 @@ class TextBuffer extends telepath.Model @load() if @loadWhenAttached # Private: Called by telepath. - beforePersistence: -> + willBePersisted: -> @modifiedWhenLastPersisted = @isModified() @digestWhenLastPersisted = @file?.getDigest() diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index dc751bf4e..98d05a91f 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -4,7 +4,7 @@ Q = require 'q' {$, $$, View} = require './space-pen-extensions' _ = require 'underscore-plus' fs = require 'fs-plus' -telepath = require 'telepath' +{TelepathicObject} = require 'telepath' EditorView = require './editor-view' Pane = require './pane' PaneColumn = require './pane-column' @@ -65,7 +65,7 @@ class WorkspaceView extends View # Private: initialize: (state={}) -> - if state instanceof telepath.Document + if state instanceof TelepathicObject @state = state panes = atom.deserializers.deserialize(state.get('panes')) else From 92b829c89ba249b65c14f6943ebab7a47ed4fc5a Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 16 Dec 2013 19:25:30 -0700 Subject: [PATCH 21/23] Upgrade to telepath 0.76.0 for deprecated shim methods --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e28c068e5..493d3fffa 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "season": "0.14.0", "semver": "1.1.4", "space-pen": "2.0.2", - "telepath": "0.75.0", + "telepath": "0.76.0", "temp": "0.5.0", "underscore-plus": "0.5.0" }, From a57083a48b7c1c35fb5063d7a2c90ed2120ee016 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 17 Dec 2013 11:18:59 -0700 Subject: [PATCH 22/23] Mark Atom global class methods with instance equivalents as 'Private:' --- src/atom.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/atom.coffee b/src/atom.coffee index fc68aa5fb..b4f5344bf 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -84,13 +84,13 @@ class Atom extends Model else null - # Public: Get the directory path to Atom's configuration area. + # Private: Get the directory path to Atom's configuration area. # # Returns the absolute path to ~/.atom @getConfigDirPath: -> @configDirPath ?= fs.absolute('~/.atom') - # Public: Get the path to Atom's storage directory. + # Private: Get the path to Atom's storage directory. # # Returns the absolute path to ~/.atom/storage @getStorageDirPath: -> @@ -100,15 +100,15 @@ class Atom extends Model @getLoadSettings: -> _.deepClone(@loadSettings ?= _.deepClone(@getCurrentWindow().loadSettings)) - # Public: + # Private: @getCurrentWindow: -> remote.getCurrentWindow() - # Public: Get the version of the Atom application. + # Private: Get the version of the Atom application. @getVersion: -> @version ?= app.getVersion() - # Public: Determine whether the current version is an official release. + # Private: Determine whether the current version is an official release. @isReleasedVersion: -> not /\w{7}/.test(@getVersion()) # Check if the release is a 7-character SHA prefix From 0438565c435c04db218dcbe7025316ae35f7de67 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 17 Dec 2013 16:46:16 -0700 Subject: [PATCH 23/23] Fix site.createDocument shim --- src/site-shim.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site-shim.coffee b/src/site-shim.coffee index e4118f385..0f1751a01 100644 --- a/src/site-shim.coffee +++ b/src/site-shim.coffee @@ -5,4 +5,4 @@ class SiteShim {@id} = @environment.state.siteId createDocument: (values) -> - @environment.create() + @environment.create(values)