Merge branch 'master' into ns-telepathic-atom-global

Conflicts:
	src/atom.coffee
This commit is contained in:
Nathan Sobo
2013-12-16 18:18:06 -07:00
12 changed files with 115 additions and 45 deletions

View File

@@ -92,8 +92,8 @@
"dev-live-reload": "0.20.0",
"editor-stats": "0.9.0",
"exception-reporting": "0.9.0",
"feedback": "0.16.0",
"find-and-replace": "0.59.0",
"feedback": "0.17.0",
"find-and-replace": "0.60.0",
"fuzzy-finder": "0.28.0",
"gists": "0.13.0",
"git-diff": "0.21.0",
@@ -104,7 +104,7 @@
"keybinding-resolver": "0.6.0",
"link": "0.11.0",
"markdown-preview": "0.22.0",
"metrics": "0.17.0",
"metrics": "0.20.0",
"package-generator": "0.23.0",
"release-notes": "0.15.0",
"settings-view": "0.50.0",
@@ -113,11 +113,11 @@
"status-bar": "0.27.0",
"styleguide": "0.18.0",
"symbols-view": "0.27.0",
"tabs": "0.15.0",
"tabs": "0.16.0",
"terminal": "0.23.0",
"timecop": "0.11.0",
"to-the-hubs": "0.15.0",
"tree-view": "0.48.0",
"to-the-hubs": "0.16.0",
"tree-view": "0.50.0",
"visual-bell": "0.6.0",
"welcome": "0.3.0",
"whitespace": "0.10.0",

View File

@@ -90,6 +90,14 @@ describe "DisplayBuffer", ->
expect(displayBuffer.lineForRow(3).text).toBe ' var pivot = items.shift(), current, left = [], '
expect(displayBuffer.lineForRow(4).text).toBe 'right = [];'
describe "when there are hard tabs", ->
beforeEach ->
buffer.setText(buffer.getText().replace(new RegExp(' ', 'g'), '\t'))
it "correctly tokenizes the hard tabs", ->
expect(displayBuffer.lineForRow(3).tokens[0].isHardTab).toBeTruthy()
expect(displayBuffer.lineForRow(3).tokens[1].isHardTab).toBeTruthy()
describe "when the buffer changes", ->
describe "when buffer lines are updated", ->
describe "when whitespace is added after the max line length", ->

View File

@@ -28,11 +28,11 @@ describe "Pane", ->
afterEach ->
atom.deserializers.remove(TestView)
describe ".initialize(items...)", ->
describe "::initialize(items...)", ->
it "displays the first item in the pane", ->
expect(pane.itemViews.find('#view-1')).toExist()
describe ".showItem(item)", ->
describe "::showItem(item)", ->
it "hides all item views except the one being shown and sets the activeItem", ->
expect(pane.activeItem).toBe view1
pane.showItem(view2)
@@ -138,7 +138,7 @@ describe "Pane", ->
expect(pane.itemViews.find('#view-2')).toExist()
expect(pane.activeView).toBe view2
describe ".destroyItem(item)", ->
describe "::destroyItem(item)", ->
describe "if the item is not modified", ->
it "removes the item and tries to call destroy on it", ->
pane.destroyItem(editor2)
@@ -196,7 +196,7 @@ describe "Pane", ->
expect(pane.getItems().indexOf(editor2)).not.toBe -1
expect(editor2.destroyed).toBeFalsy()
describe ".removeItem(item)", ->
describe "::removeItem(item)", ->
it "removes the item from the items list and shows the next item if it was showing", ->
pane.removeItem(view1)
expect(pane.getItems()).toEqual [editor1, view2, editor2]
@@ -244,7 +244,7 @@ describe "Pane", ->
pane.removeItem(editor1)
expect(pane.itemViews.find('.editor')).not.toExist()
describe ".moveItem(item, index)", ->
describe "::moveItem(item, index)", ->
it "moves the item to the given index and emits a 'pane:item-moved' event with the item and the new index", ->
itemMovedHandler = jasmine.createSpy("itemMovedHandler")
pane.on 'pane:item-moved', itemMovedHandler
@@ -267,7 +267,7 @@ describe "Pane", ->
expect(itemMovedHandler.argsForCall[0][1..2]).toEqual [editor1, 1]
itemMovedHandler.reset()
describe ".moveItemToPane(item, pane, index)", ->
describe "::moveItemToPane(item, pane, index)", ->
[pane2, view3] = []
beforeEach ->
@@ -299,19 +299,6 @@ describe "Pane", ->
pane2.showItemAtIndex(1)
expect(pane2.activeView.data('preservative')).toBe 1234
describe "core:close", ->
it "destroys the active item and does not bubble the event", ->
containerCloseHandler = jasmine.createSpy("containerCloseHandler")
container.on 'core:close', containerCloseHandler
pane.showItem(editor1)
initialItemCount = pane.getItems().length
pane.trigger 'core:close'
expect(pane.getItems().length).toBe initialItemCount - 1
expect(editor1.destroyed).toBeTruthy()
expect(containerCloseHandler).not.toHaveBeenCalled()
describe "pane:close", ->
it "destroys all items and removes the pane", ->
pane.showItem(editor1)
@@ -327,20 +314,20 @@ describe "Pane", ->
expect(editor2.destroyed).toBeTruthy()
expect(pane.getItems()).toEqual [editor1]
describe "core:save", ->
describe "::saveActiveItem()", ->
describe "when the current item has a uri", ->
describe "when the current item has a save method", ->
it "saves the current item", ->
spyOn(editor2, 'save')
pane.showItem(editor2)
pane.trigger 'core:save'
pane.saveActiveItem()
expect(editor2.save).toHaveBeenCalled()
describe "when the current item has no save method", ->
it "does nothing", ->
pane.activeItem.getUri = -> 'you are eye'
expect(pane.activeItem.save).toBeUndefined()
pane.trigger 'core:save'
pane.saveActiveItem()
describe "when the current item has no uri", ->
beforeEach ->
@@ -352,7 +339,7 @@ describe "Pane", ->
spyOn(newEditor, 'saveAs')
pane.showItem(newEditor)
pane.trigger 'core:save'
pane.saveActiveItem()
expect(atom.showSaveDialogSync).toHaveBeenCalled()
expect(newEditor.saveAs).toHaveBeenCalledWith('/selected/path')
@@ -360,10 +347,10 @@ describe "Pane", ->
describe "when the current item has no saveAs method", ->
it "does nothing", ->
expect(pane.activeItem.saveAs).toBeUndefined()
pane.trigger 'core:save'
pane.saveActiveItem()
expect(atom.showSaveDialogSync).not.toHaveBeenCalled()
describe "core:save-as", ->
describe "::saveActiveItemAs()", ->
beforeEach ->
spyOn(atom, 'showSaveDialogSync').andReturn('/selected/path')
@@ -372,7 +359,7 @@ describe "Pane", ->
spyOn(editor2, 'saveAs')
pane.showItem(editor2)
pane.trigger 'core:save-as'
pane.saveActiveItemAs()
expect(atom.showSaveDialogSync).toHaveBeenCalledWith(path.dirname(editor2.getPath()))
expect(editor2.saveAs).toHaveBeenCalledWith('/selected/path')
@@ -380,7 +367,7 @@ describe "Pane", ->
describe "when the current item does not have a saveAs method", ->
it "does nothing", ->
expect(pane.activeItem.saveAs).toBeUndefined()
pane.trigger 'core:save-as'
pane.saveActiveItemAs()
expect(atom.showSaveDialogSync).not.toHaveBeenCalled()
describe "pane:show-next-item and pane:show-previous-item", ->
@@ -433,7 +420,7 @@ describe "Pane", ->
waitsFor ->
pane.items.length == 4
describe ".remove()", ->
describe "::remove()", ->
it "destroys all the pane's items", ->
pane.remove()
expect(editor1.destroyed).toBeTruthy()
@@ -502,7 +489,7 @@ describe "Pane", ->
pane.remove()
expect(atom.workspaceView.focus).not.toHaveBeenCalled()
describe ".getNextPane()", ->
describe "::getNextPane()", ->
it "returns the next pane if one exists, wrapping around from the last pane to the first", ->
pane.showItem(editor1)
expect(pane.getNextPane()).toBeUndefined
@@ -683,7 +670,7 @@ describe "Pane", ->
expect(container.children('.pane').length).toBe 1
expect(pane1.outerWidth()).toBe container.width()
describe ".itemForUri(uri)", ->
describe "::itemForUri(uri)", ->
it "returns the item for which a call to .getUri() returns the given uri", ->
expect(pane.itemForUri(editor1.getUri())).toBe editor1
expect(pane.itemForUri(editor2.getUri())).toBe editor2

View File

@@ -555,3 +555,31 @@ describe "WorkspaceView", ->
expect(workspace.getActivePaneItem().getUri()).toBe 'b'
workspace.reopenItemSync()
expect(workspace.getActivePaneItem().getUri()).toBe 'a'
describe "core:close", ->
it "closes the active editor until there are none", ->
atom.project.openSync('../sample.txt')
expect(atom.workspaceView.getActivePane().getItems()).toHaveLength 1
atom.workspaceView.trigger('core:close')
expect(atom.workspaceView.getActivePane()).not.toBeDefined()
atom.workspaceView.trigger('core:close')
expect(atom.workspaceView.getActivePane()).not.toBeDefined()
describe "core:save", ->
it "saves active editor until there are none", ->
editor = atom.project.openSync('../sample.txt')
spyOn(editor, 'save')
atom.workspaceView.getActivePane().showItem(editor)
atom.workspaceView.trigger('core:save')
expect(editor.save).toHaveBeenCalled()
describe "core:save-as", ->
beforeEach ->
spyOn(atom, 'showSaveDialogSync').andReturn('/selected/path')
it "saves active editor until there are none", ->
editor = atom.project.openSync('../sample.txt')
spyOn(editor, 'saveAs')
atom.workspaceView.getActivePane().showItem(editor)
atom.workspaceView.trigger('core:save-as')
expect(editor.saveAs).toHaveBeenCalled()

View File

@@ -106,7 +106,7 @@ class Atom extends Model
# Public: Get the version of the Atom application.
@getVersion: ->
app.getVersion()
@version ?= app.getVersion()
# Public: Determine whether the current version is an official release.
@isReleasedVersion: ->

View File

@@ -11,6 +11,7 @@ _ = require 'underscore-plus'
module.exports =
class AtomWindow
@iconPath: path.resolve(__dirname, '..', '..', 'resources', 'atom.png')
@includeShellLoadTime: true
browserWindow: null
loaded: null
@@ -30,6 +31,12 @@ class AtomWindow
loadSettings = _.extend({}, settings)
loadSettings.windowState ?= ''
# Only send to the first non-spec window created
if @constructor.includeShellLoadTime and not @isSpec
@constructor.includeShellLoadTime = false
loadSettings.shellLoadTime ?= Date.now() - global.shellStartTime
loadSettings.initialPath = pathToOpen
if fs.statSyncNoException(pathToOpen).isFile?()
loadSettings.initialPath = path.dirname(pathToOpen)

View File

@@ -1,4 +1,4 @@
startTime = Date.now()
global.shellStartTime = Date.now()
autoUpdater = require 'auto-updater'
crashReporter = require 'crash-reporter'
@@ -62,7 +62,7 @@ delegate.browserMainParts.preMainMessageLoopRun = ->
AtomApplication = require './atom-application'
AtomApplication.open(args)
console.log("App load time: #{Date.now() - startTime}ms") unless args.test
console.log("App load time: #{Date.now() - global.shellStartTime}ms") unless args.test
global.devResourcePath = path.join(app.getHomeDir(), 'github', 'atom')

View File

@@ -63,9 +63,6 @@ class Pane extends View
unless activeItemUri? and @showItemForUri(activeItemUri)
@showItem(@items[0]) if @items.length > 0
@command 'core:close', @destroyActiveItem
@command 'core:save', @saveActiveItem
@command 'core:save-as', @saveActiveItemAs
@command 'pane:save-items', @saveItems
@command 'pane:show-next-item', @showNextItem
@command 'pane:show-previous-item', @showPreviousItem

View File

@@ -57,6 +57,8 @@ class Token
outputTokens
else
return [this] if @isAtomic
if breakOutLeadingWhitespace
return [this] unless /^[ ]|\t/.test(@value)
else

View File

@@ -73,6 +73,25 @@ class WindowEventHandler
e.preventDefault()
atom.contextMenu.showForEvent(e)
@handleNativeKeybindings()
# Private: Wire commands that should be handled by the native menu
# for elements with the `.native-key-bindings` class.
handleNativeKeybindings: ->
menu = null
bindCommandToAction = (command, action) =>
@subscribe $(document), command, (event) ->
if event.target.webkitMatchesSelector('.native-key-bindings')
menu ?= require('remote').require('menu')
menu.sendActionToFirstResponder(action)
true
bindCommandToAction('core:copy', 'copy:')
bindCommandToAction('core:paste', 'paste:')
bindCommandToAction('core:undo', 'undo:')
bindCommandToAction('core:redo', 'redo:')
bindCommandToAction('core:select-all', 'selectAll:')
openLink: (event) =>
location = $(event.target).attr('href')
if location and location[0] isnt '#' and /^https?:\/\//.test(location)
@@ -105,7 +124,10 @@ class WindowEventHandler
nextTabIndex = tabIndex
nextElement = element
(nextElement ? lowestElement).focus()
if nextElement?
nextElement.focus()
else if lowestElement?
lowestElement.focus()
focusPrevious: =>
focusedTabIndex = parseInt($(':focus').attr('tabindex')) or Infinity
@@ -123,4 +145,7 @@ class WindowEventHandler
previousTabIndex = tabIndex
previousElement = element
(previousElement ? highestElement).focus()
if previousElement?
previousElement.focus()
else if highestElement?
highestElement.focus()

View File

@@ -126,6 +126,10 @@ class WorkspaceView extends View
@command 'pane:reopen-closed-item', => @reopenItemSync()
@command 'core:close', => @destroyActivePaneItem()
@command 'core:save', => @saveActivePaneItem()
@command 'core:save-as', => @saveActivePaneItemAs()
# Private:
serialize: ->
state = @state.clone()
@@ -280,6 +284,18 @@ class WorkspaceView extends View
getActiveView: ->
@panes.getActiveView()
# Public: destroy/close the active item.
destroyActivePaneItem: ->
@getActivePane()?.destroyActiveItem()
# Public: save the active item.
saveActivePaneItem: ->
@getActivePane()?.saveActiveItem()
# Public: save the active item as.
saveActivePaneItemAs: ->
@getActivePane()?.saveActiveItemAs()
# Public: Focuses the previous pane by id.
focusPreviousPane: -> @panes.focusPreviousPane()

2
vendor/apm vendored

Submodule vendor/apm updated: 77bc20a814...dd0b98fb38