Merge branch 'master' into paste-indentation

This commit is contained in:
Nathan Sobo
2012-10-24 12:37:50 -06:00
29 changed files with 172 additions and 126 deletions

View File

@@ -9,10 +9,7 @@ TextMateBundle = require 'text-mate-bundle'
TextMateTheme = require 'text-mate-theme'
require 'window'
requireStylesheet "jasmine.css"
TextMateBundle.loadAll()
TextMateTheme.loadAll()
RootView.prototype.loadUserConfiguration = ->

View File

@@ -10,7 +10,7 @@ describe "editor.", ->
beforeEach ->
window.rootViewParentSelector = '#jasmine-content'
window.startup()
window.attachRootView()
rootView.project.setPath(require.resolve('benchmark/fixtures'))
editor = rootView.getActiveEditor()

View File

@@ -1319,6 +1319,27 @@ describe "EditSession", ->
expect(buffer.lineForRow(1)).toBe "var sort = function(items) {"
expect(editSession.getSelectedBufferRange()).toEqual [[1, 3 - editSession.tabLength], [1, 3 - editSession.tabLength]]
it "outdents when indent is less than a tab length", ->
editSession.insertText(' ')
editSession.outdentSelectedRows()
expect(buffer.lineForRow(0)).toBe "var quicksort = function () {"
it "outdents a single hard tab when indent is multiple hard tabs and and the session is using soft tabs", ->
editSession.insertText('\t\t')
editSession.outdentSelectedRows()
expect(buffer.lineForRow(0)).toBe "\tvar quicksort = function () {"
editSession.outdentSelectedRows()
expect(buffer.lineForRow(0)).toBe "var quicksort = function () {"
it "outdents when a mix of hard tabs and soft tabs are used", ->
editSession.insertText('\t ')
editSession.outdentSelectedRows()
expect(buffer.lineForRow(0)).toBe " var quicksort = function () {"
editSession.outdentSelectedRows()
expect(buffer.lineForRow(0)).toBe " var quicksort = function () {"
editSession.outdentSelectedRows()
expect(buffer.lineForRow(0)).toBe "var quicksort = function () {"
describe "when one line is selected", ->
it "outdents line and retains editSession", ->
editSession.setSelectedBufferRange([[1,4], [1,14]])

View File

@@ -3,7 +3,7 @@ fs = require 'fs'
describe "Window", ->
beforeEach ->
window.startup(require.resolve('fixtures'))
window.attachRootView(require.resolve('fixtures'))
afterEach ->
window.shutdown()
@@ -13,7 +13,7 @@ describe "Window", ->
describe ".close()", ->
it "is triggered by the 'close' event", ->
spyOn window, 'close'
$(window).trigger 'close'
$(window).trigger 'core:close'
expect(window.close).toHaveBeenCalled()
describe ".reload()", ->

View File

@@ -31,9 +31,11 @@ describe "Autocomplete", ->
expect(leftEditor.find('.autocomplete')).toExist()
expect(rightEditor.find('.autocomplete')).not.toExist()
leftEditor.trigger 'autocomplete:cancel'
rightEditor.trigger 'autocomplete:attach'
autoCompleteView = leftEditor.find('.autocomplete').view()
autoCompleteView.trigger 'core:cancel'
expect(leftEditor.find('.autocomplete')).not.toExist()
rightEditor.trigger 'autocomplete:attach'
expect(rightEditor.find('.autocomplete')).toExist()
expect(Autocomplete.prototype.initialize).not.toHaveBeenCalled()
@@ -138,14 +140,14 @@ describe "Autocomplete", ->
expect(editor.getSelection().isEmpty()).toBeTruthy()
expect(editor.find('.autocomplete')).not.toExist()
describe 'autocomplete:confirm event', ->
describe 'core:confirm event', ->
describe "where there are matches", ->
describe "where there is no selection", ->
it "closes the menu and moves the cursor to the end", ->
editor.getBuffer().insert([10,0] ,"extra:sh:extra")
editor.setCursorBufferPosition([10,8])
autocomplete.attach()
miniEditor.trigger "autocomplete:confirm"
miniEditor.trigger "core:confirm"
expect(editor.lineForBufferRow(10)).toBe "extra:shift:extra"
expect(editor.getCursorBufferPosition()).toEqual [10,11]
@@ -160,14 +162,14 @@ describe "Autocomplete", ->
expect(autocomplete.matchesList.find('li').length).toBe 1
expect(autocomplete.matchesList.find('li')).toHaveText ('No matches found')
miniEditor.trigger "autocomplete:confirm"
miniEditor.trigger "core:confirm"
expect(editor.lineForBufferRow(10)).toBe "xxx"
expect(editor.getCursorBufferPosition()).toEqual [10,3]
expect(editor.getSelection().isEmpty()).toBeTruthy()
expect(editor.find('.autocomplete')).not.toExist()
describe 'autocomplete:cancel event', ->
describe 'core:cancel event', ->
it 'does not replace selection, removes autocomplete view and returns focus to editor', ->
editor.getBuffer().insert([10,0] ,"extra:so:extra")
editor.setSelectedBufferRange [[10,7], [10,8]]
@@ -175,7 +177,7 @@ describe "Autocomplete", ->
autocomplete.attach()
editor.setCursorBufferPosition [0, 0] # even if selection changes before cancel, it should work
miniEditor.trigger "autocomplete:cancel"
miniEditor.trigger "core:cancel"
expect(editor.lineForBufferRow(10)).toBe "extra:so:extra"
expect(editor.getSelection().getBufferRange()).toEqual originalSelectionBufferRange
@@ -186,12 +188,12 @@ describe "Autocomplete", ->
editor.setCursorBufferPosition([10, 0])
autocomplete.attach()
miniEditor.trigger 'autocomplete:confirm'
miniEditor.trigger 'core:confirm'
expect(editor.lineForBufferRow(10)).toBe 'quicksort'
editor.setCursorBufferPosition([11, 0])
autocomplete.attach()
miniEditor.trigger 'autocomplete:cancel'
miniEditor.trigger 'core:cancel'
expect(editor.lineForBufferRow(10)).toBe 'quicksort'
describe 'move-up event', ->

View File

@@ -78,10 +78,10 @@ describe "CommandPanel", ->
rootView2.deactivate()
describe "when command-panel:close is triggered on the command panel", ->
describe "when core:close is triggered on the command panel", ->
it "detaches the command panel", ->
commandPanel.attach()
commandPanel.trigger('command-panel:close')
commandPanel.trigger('core:close')
expect(commandPanel.hasParent()).toBeFalsy()
describe "when command-panel:toggle is triggered on the root view", ->
@@ -188,12 +188,12 @@ describe "CommandPanel", ->
describe "when the command panel is not visible", ->
it "shows the command panel and focuses the mini editor, but does not show the preview list", ->
describe "when command-panel:unfocus is triggered on the command panel", ->
describe "when tool-pane:unfocus is triggered on the command panel", ->
it "returns focus to the root view but does not hide the command panel", ->
rootView.attachToDom()
commandPanel.attach()
expect(commandPanel.miniEditor.hiddenInput).toMatchSelector ':focus'
commandPanel.trigger 'command-panel:unfocus'
commandPanel.trigger 'tool-pane:unfocus'
expect(commandPanel.hasParent()).toBeTruthy()
expect(commandPanel.miniEditor.hiddenInput).not.toMatchSelector ':focus'
@@ -370,16 +370,16 @@ describe "CommandPanel", ->
_.times previewList.getOperations().length, -> previewList.trigger 'core:move-up'
describe "when command-panel:execute is triggered on the preview list", ->
describe "when core:confirm is triggered on the preview list", ->
it "opens the operation's buffer, selects the search result, and focuses the active editor", ->
spyOn(rootView, 'focus')
executeHandler = jasmine.createSpy('executeHandler')
commandPanel.on 'command-panel:execute', executeHandler
commandPanel.on 'core:confirm', executeHandler
_.times 4, -> previewList.trigger 'core:move-down'
operation = previewList.getSelectedOperation()
previewList.trigger 'command-panel:execute'
previewList.trigger 'core:confirm'
editSession = rootView.getActiveEditSession()
expect(editSession.buffer.getPath()).toBe project.resolve(operation.getPath())

View File

@@ -14,41 +14,47 @@ describe "MarkdownPreview", ->
afterEach ->
rootView.deactivate()
describe "@attach", ->
it "attaches to a .md file", ->
describe "markdown-preview:toggle event", ->
it "toggles on/off a preview for a .md file", ->
rootView.open('file.md')
editor = rootView.getActiveEditor()
expect(rootView.find('.markdown-preview')).not.toExist()
spyOn(markdownPreview, 'loadHtml')
editor.trigger('markdown-preview:attach')
editor.trigger('markdown-preview:toggle')
markdownPreviewView = rootView.find('.markdown-preview')?.view()
expect(rootView.find('.markdown-preview')).toExist()
expect(markdownPreview.loadHtml).toHaveBeenCalled();
markdownPreviewView.trigger('markdown-preview:toggle')
expect(rootView.find('.markdown-preview')).not.toExist()
it "attaches to a .markdown file", ->
it "displays a preview for a .markdown file", ->
rootView.open('file.markdown')
editor = rootView.getActiveEditor()
expect(rootView.find('.markdown-preview')).not.toExist()
spyOn(markdownPreview, 'loadHtml')
editor.trigger('markdown-preview:attach')
editor.trigger('markdown-preview:toggle')
expect(rootView.find('.markdown-preview')).toExist()
expect(markdownPreview.loadHtml).toHaveBeenCalled();
it "doesn't attach to a .js file", ->
it "does not display a preview for non-markdown file", ->
rootView.open('file.js')
editor = rootView.getActiveEditor()
expect(rootView.find('.markdown-preview')).not.toExist()
spyOn(markdownPreview, 'loadHtml')
editor.trigger('markdown-preview:attach')
editor.trigger('markdown-preview:toggle')
expect(rootView.find('.markdown-preview')).not.toExist()
expect(markdownPreview.loadHtml).not.toHaveBeenCalled();
describe "@detach", ->
it "detaches from a .md file", ->
describe "core:cancel event", ->
it "removes markdown preview", ->
rootView.open('file.md')
editor = rootView.getActiveEditor()
expect(rootView.find('.markdown-preview')).not.toExist()
spyOn(markdownPreview, 'loadHtml')
editor.trigger('markdown-preview:attach')
expect(rootView.find('.markdown-preview')).toExist()
markdownPreview.trigger('markdown-preview:detach')
editor.trigger('markdown-preview:toggle')
markdownPreviewView = rootView.find('.markdown-preview')?.view()
expect(markdownPreviewView).toExist()
markdownPreviewView.trigger('core:cancel')
expect(rootView.find('.markdown-preview')).not.toExist()

View File

@@ -183,13 +183,13 @@ describe "TreeView", ->
expect(treeView.hasParent()).toBeTruthy()
expect(treeView.focus).toHaveBeenCalled()
describe "when tree-view:unfocus is triggered on the tree view", ->
describe "when tool-panel:unfocus is triggered on the tree view", ->
it "surrenders focus to the root view but remains open", ->
rootView.open() # When we trigger 'tree-view:unfocus' below, we want an editor to become focused
rootView.open() # When we trigger 'tool-panel:unfocus' below, we want an editor to become focused
rootView.attachToDom()
treeView.focus()
expect(treeView).toMatchSelector(':focus')
treeView.trigger 'tree-view:unfocus'
treeView.trigger 'tool-panel:unfocus'
expect(treeView).toBeVisible()
expect(treeView).not.toMatchSelector(':focus')
expect(rootView.getActiveEditor().isFocused).toBeTruthy()
@@ -616,7 +616,7 @@ describe "TreeView", ->
it "add a file, closes the dialog and selects the file in the tree-view", ->
newPath = fs.join(dirPath, "new-test-file.txt")
addDialog.miniEditor.insertText(fs.base(newPath))
addDialog.trigger 'tree-view:confirm'
addDialog.trigger 'core:confirm'
expect(fs.exists(newPath)).toBeTruthy()
expect(fs.isFile(newPath)).toBeTruthy()
expect(addDialog.parent()).not.toExist()
@@ -633,7 +633,7 @@ describe "TreeView", ->
newPath = fs.join(dirPath, "new-test-file.txt")
fs.write(newPath, '')
addDialog.miniEditor.insertText(fs.base(newPath))
addDialog.trigger 'tree-view:confirm'
addDialog.trigger 'core:confirm'
expect(addDialog.prompt.text()).toContain 'Error'
expect(addDialog.prompt.text()).toContain 'already exists'
@@ -646,7 +646,7 @@ describe "TreeView", ->
treeView.attachToDom()
newPath = fs.join(dirPath, "new/dir")
addDialog.miniEditor.insertText("new/dir/")
addDialog.trigger 'tree-view:confirm'
addDialog.trigger 'core:confirm'
expect(fs.exists(newPath)).toBeTruthy()
expect(fs.isDirectory(newPath)).toBeTruthy()
expect(addDialog.parent()).not.toExist()
@@ -659,7 +659,7 @@ describe "TreeView", ->
treeView.attachToDom()
newPath = fs.join(dirPath, "new2/")
addDialog.miniEditor.insertText("new2/")
addDialog.trigger 'tree-view:confirm'
addDialog.trigger 'core:confirm'
expect(fs.exists(newPath)).toBeTruthy()
expect(fs.isDirectory(newPath)).toBeTruthy()
expect(addDialog.parent()).not.toExist()
@@ -673,17 +673,17 @@ describe "TreeView", ->
newPath = fs.join(dirPath, "new-dir")
fs.makeDirectory(newPath)
addDialog.miniEditor.insertText("new-dir/")
addDialog.trigger 'tree-view:confirm'
addDialog.trigger 'core:confirm'
expect(addDialog.prompt.text()).toContain 'Error'
expect(addDialog.prompt.text()).toContain 'already exists'
expect(addDialog.prompt).toHaveClass('error')
expect(addDialog.hasParent()).toBeTruthy()
describe "when 'tree-view:cancel' is triggered on the add dialog", ->
describe "when 'core:cancel' is triggered on the add dialog", ->
it "removes the dialog and focuses the tree view", ->
treeView.attachToDom()
addDialog.trigger 'tree-view:cancel'
addDialog.trigger 'core:cancel'
expect(addDialog.parent()).not.toExist()
expect(treeView).toMatchSelector(':focus')
@@ -741,7 +741,7 @@ describe "TreeView", ->
newPath = fs.join(rootDirPath, 'renamed-test-file.txt')
moveDialog.miniEditor.setText(newPath)
moveDialog.trigger 'tree-view:confirm'
moveDialog.trigger 'core:confirm'
expect(fs.exists(newPath)).toBeTruthy()
expect(fs.exists(filePath)).toBeFalsy()
@@ -760,7 +760,7 @@ describe "TreeView", ->
newPath = fs.join(rootDirPath, 'new/directory', 'renamed-test-file.txt')
moveDialog.miniEditor.setText(newPath)
moveDialog.trigger 'tree-view:confirm'
moveDialog.trigger 'core:confirm'
expect(fs.exists(newPath)).toBeTruthy()
expect(fs.exists(filePath)).toBeFalsy()
@@ -774,17 +774,17 @@ describe "TreeView", ->
newPath = fs.join(rootDirPath, 'target.txt')
moveDialog.miniEditor.setText(newPath)
moveDialog.trigger 'tree-view:confirm'
moveDialog.trigger 'core:confirm'
expect(moveDialog.prompt.text()).toContain 'Error'
expect(moveDialog.prompt.text()).toContain 'already exists'
expect(moveDialog.prompt).toHaveClass('error')
expect(moveDialog.hasParent()).toBeTruthy()
describe "when 'tree-view:cancel' is triggered on the move dialog", ->
describe "when 'core:cancel' is triggered on the move dialog", ->
it "removes the dialog and focuses the tree view", ->
treeView.attachToDom()
moveDialog.trigger 'tree-view:cancel'
moveDialog.trigger 'core:cancel'
expect(moveDialog.parent()).not.toExist()
expect(treeView).toMatchSelector(':focus')

View File

@@ -14,8 +14,6 @@ require 'window'
atom.showDevTools()
requireStylesheet "jasmine.css"
TextMateBundle.loadAll()
TextMateTheme.loadAll()
defaultTitle = document.title
pathsWithSubscriptions = null

View File

@@ -11,9 +11,17 @@ describe 'Child Processes', ->
it "returns a promise that resolves to stdout and stderr", ->
waitsForPromise ->
cmd = "echo 'good' && echo 'bad' >&2"
ChildProcess.exec(cmd).done (stdout, stderr) ->
expect(stdout).toBe 'good\n'
expect(stderr).toBe 'bad\n'
standardOutput = ''
errorOutput = ''
options =
stdout: (data) ->
standardOutput += data
stderr: (data) ->
errorOutput += data
ChildProcess.exec(cmd, options).done ->
expect(standardOutput).toBe 'good\n'
expect(errorOutput).toBe 'bad\n'
describe "when options are given", ->
it "calls the options.stdout callback when new data is received on stdout", ->
@@ -89,6 +97,10 @@ describe 'Child Processes', ->
it "executes the callback with error set to the exit status", ->
waitsForPromise shouldReject: true, ->
cmd = "echo 'bad' >&2 && exit 2"
ChildProcess.exec(cmd).fail (error) ->
errorOutput = ''
options =
stderr: (data) ->
errorOutput += data
ChildProcess.exec(cmd, options).fail (error) ->
expect(error.exitStatus).toBe 2
expect(error.stderr).toBe "bad\n"
expect(errorOutput).toBe "bad\n"

View File

@@ -108,6 +108,7 @@ class EditSession
setSoftWrap: (@softWrap) ->
getTabText: -> new Array(@tabLength + 1).join(" ")
getTabLength: -> @tabLength
clipBufferPosition: (bufferPosition) ->
@buffer.clipPosition(bufferPosition)

View File

@@ -18,6 +18,7 @@ class Keymap
'meta-n': 'new-window'
'meta-,': 'open-user-configuration'
'meta-o': 'open'
'meta-w': 'core:close'
$(document).on 'new-window', => atom.newWindow()
$(document).on 'open-user-configuration', => atom.open(atom.configFilePath)

View File

@@ -1,10 +1,11 @@
window.keymap.bindKeys 'body'
'alt-meta-i': 'toggle-dev-tools'
'enter': 'core:confirm'
'escape': 'core:cancel'
'meta-w': 'core:close'
up: 'core:move-up'
down: 'core:move-down'
left: 'core:move-left'
right: 'core:move-right'
'up': 'core:move-up'
'down': 'core:move-down'
'left': 'core:move-left'
'right': 'core:move-right'
'shift-up': 'core:select-up'
'shift-down': 'core:select-down'
'shift-left': 'core:select-left'
@@ -18,10 +19,15 @@ window.keymap.bindKeys 'body'
'meta-x': 'core:cut'
'meta-c': 'core:copy'
'meta-v': 'core:paste'
pageup: 'core:page-up'
pagedown: 'core:page-down'
'pageup': 'core:page-up'
'pagedown': 'core:page-down'
'meta-S': 'window:save-all'
'meta-+': 'window:increase-font-size'
'meta--': 'window:decrease-font-size'
'ctrl-w w': 'window:focus-next-pane'
'alt-meta-i': 'toggle-dev-tools'
window.keymap.bindKeys '.tool-panel'
'escape': 'tool-panel:unfocus'

View File

@@ -249,10 +249,10 @@ class Selection
outdentSelectedRows: ->
range = @getBufferRange()
buffer = @editSession.buffer
leadingTabRegex = new RegExp("^#{@editSession.getTabText()}")
leadingTabRegex = new RegExp("^ {1,#{@editSession.getTabLength()}}|\t")
for row in [range.start.row..range.end.row]
if leadingTabRegex.test buffer.lineForRow(row)
buffer.delete [[row, 0], [row, @editSession.tabLength]]
if matchLength = buffer.lineForRow(row).match(leadingTabRegex)?[0].length
buffer.delete [[row, 0], [row, matchLength]]
toggleLineComments: ->
@modifySelection =>

View File

@@ -8,6 +8,9 @@ fs = require 'fs'
_ = require 'underscore'
$ = require 'jquery'
{CoffeeScript} = require 'coffee-script'
RootView = require 'root-view'
require 'jquery-extensions'
require 'underscore-extensions'
windowAdditions =
rootViewParentSelector: 'body'
@@ -15,16 +18,28 @@ windowAdditions =
keymap: null
platform: $native.getPlatform()
startup: (path) ->
# This method runs when the file is required. Any code here will run
# in all environments: spec, benchmark, and application
startup: ->
TextMateBundle.loadAll()
TextMateTheme.loadAll()
@setUpKeymap()
$(window).on 'core:close', => @close()
@attachRootView(path)
$(window).on 'close', => @close()
# This method is intended only to be run when starting a normal application
# Note: RootView assigns itself on window on initialization so that
# window.rootView is available when loading user configuration
attachRootView: (pathToOpen) ->
if rootViewState = atom.getRootViewStateForPath(pathToOpen)
RootView.deserialize(rootViewState)
else
new RootView(pathToOpen)
$(@rootViewParentSelector).append(@rootView)
$(window).focus()
$(window).on 'beforeunload', =>
@shutdown()
false
$(window).focus()
shutdown: ->
@rootView.deactivate()
@@ -42,16 +57,6 @@ windowAdditions =
@_handleKeyEvent = (e) => @keymap.handleKeyEvent(e)
$(document).on 'keydown', @_handleKeyEvent
# Note: RootView assigns itself on window on initialization so that
# window.rootView is available when loading user configuration
attachRootView: (pathToOpen) ->
if rootViewState = atom.getRootViewStateForPath(pathToOpen)
RootView.deserialize(rootViewState)
else
new RootView(pathToOpen)
$(@rootViewParentSelector).append @rootView
requireStylesheet: (path) ->
unless fullPath = require.resolve(path)
throw new Error("requireStylesheet could not find a file at path '#{path}'")
@@ -91,12 +96,7 @@ windowAdditions =
console.log description, result
window[key] = value for key, value of windowAdditions
window.setUpKeymap()
RootView = require 'root-view'
require 'jquery-extensions'
require 'underscore-extensions'
window.startup()
requireStylesheet 'reset.css'
requireStylesheet 'atom.css'

View File

@@ -26,8 +26,7 @@ class Autocomplete extends View
@activate: (rootView) ->
new Autocomplete(editor) for editor in rootView.getEditors()
rootView.on 'editor-open', (e, editor) ->
editor.autoComplete = new Autocomplete(editor) unless editor.is('.autocomplete .mini')
rootView.on 'editor-open', (e, editor) -> new Autocomplete(editor) unless editor.mini
initialize: (@editor) ->
requireStylesheet 'autocomplete.css'
@@ -39,8 +38,8 @@ class Autocomplete extends View
@editor.on 'before-remove', => @currentBuffer?.off '.autocomplete'
@editor.command 'autocomplete:attach', => @attach()
@editor.command 'autocomplete:cancel', => @cancel()
@command 'autocomplete:confirm', => @confirm()
@command 'core:cancel', => @cancel()
@command 'core:confirm', => @confirm()
@matchesList.on 'mousedown', (e) =>
index = $(e.target).attr('index')

View File

@@ -2,6 +2,7 @@ window.keymap.bindKeys '.editor',
'ctrl-space': 'autocomplete:attach'
window.keymap.bindKeys '.autocomplete .editor',
'enter': 'autocomplete:confirm'
'escape': 'autocomplete:cancel'
'ctrl-space': 'autocomplete:cancel'
'ctrl-space': 'core:cancel'
window.keymap.bindKeys ".autocomplete .mini.editor input",
'enter': 'core:confirm'

View File

@@ -33,7 +33,7 @@ class CommandPanel extends View
commandPanel
@content: (rootView) ->
@div class: 'command-panel', =>
@div class: 'command-panel tool-pane', =>
@subview 'previewList', new PreviewList(rootView)
@div class: 'prompt-and-editor', =>
@div ':', class: 'prompt', outlet: 'prompt'
@@ -50,9 +50,9 @@ class CommandPanel extends View
@history ?= []
@historyIndex = @history.length
@command 'command-panel:unfocus', => @rootView.focus()
@command 'command-panel:close', => @detach()
@command 'command-panel:execute', => @execute()
@command 'tool-pane:unfocus', => @rootView.focus()
@command 'core:close', => @detach()
@command 'core:confirm', => @execute()
@rootView.command 'command-panel:toggle', => @toggle()
@rootView.command 'command-panel:toggle-preview', => @togglePreview()

View File

@@ -5,9 +5,7 @@ window.keymap.bindKeys '*'
'meta-F': 'command-panel:find-in-project'
window.keymap.bindKeys '.command-panel .preview-list, .command-panel .editor input',
'meta-w': 'command-panel:close'
escape: 'command-panel:unfocus'
enter: 'command-panel:execute'
'enter': 'core:confirm'
window.keymap.bindKeys '.editor',
'meta-g': 'command-panel:repeat-relative-address'

View File

@@ -14,7 +14,7 @@ class PreviewList extends ScrollView
super
@on 'core:move-down', => @selectNextOperation()
@on 'core:move-up', => @selectPreviousOperation()
@on 'command-panel:execute', => @executeSelectedOperation()
@on 'core:confirm', => @executeSelectedOperation()
@on 'mousedown', 'li', (e) =>
@setSelectedOperationIndex(parseInt($(e.target).closest('li').data('index')))

View File

@@ -19,7 +19,6 @@
margin: 4px 0;
}
.event-palette li .right {
float: right;
}

View File

@@ -1,8 +1,5 @@
{View, $$} = require 'space-pen'
SelectList = require 'select-list'
stringScore = require 'stringscore'
fuzzyFilter = require 'fuzzy-filter'
$ = require 'jquery'
_ = require 'underscore'
Editor = require 'editor'

View File

@@ -1,5 +1,5 @@
window.keymap.bindKeys '.editor',
'meta-P': 'markdown-preview:attach'
'meta-P': 'markdown-preview:toggle'
window.keymap.bindKeys '.markdown-preview',
'escape': 'markdown-preview:detach'
'meta-P': 'markdown-preview:toggle'

View File

@@ -15,13 +15,18 @@ class MarkdownPreview extends ScrollView
initialize: (@rootView) ->
super
@rootView.command 'markdown-preview:attach', =>
path = rootView.getActiveEditor()?.getPath()
@attach() if @isMarkdownFile(path)
@rootView.command 'markdown-preview:toggle', => @toggle()
@command 'core:cancel', => @detach()
@command 'markdown-preview:detach', => @detach()
toggle: ->
if @hasParent()
@detach()
else
@attach()
attach: ->
path = rootView.getActiveEditor()?.getPath()
return unless @isMarkdownFile(path)
@rootView.append(this)
@markdownBody.hide()
@markdownSpinner.show()

View File

@@ -12,8 +12,8 @@ class Dialog extends View
initialize: ({path, @onConfirm, select} = {}) ->
@miniEditor.focus()
@on 'tree-view:confirm', => @onConfirm(@miniEditor.getText())
@on 'tree-view:cancel', => @cancel()
@on 'core:confirm', => @onConfirm(@miniEditor.getText())
@on 'core:cancel', => @cancel()
@miniEditor.on 'focusout', => @remove()
@miniEditor.setText(path)

View File

@@ -3,8 +3,6 @@ window.keymap.bindKeys '#root-view'
'ctrl-meta-1': 'tree-view:reveal-active-file'
window.keymap.bindKeys '.tree-view'
'escape': 'tree-view:unfocus'
'meta-w': 'tree-view:toggle'
'right': 'tree-view:expand-directory'
'left': 'tree-view:collapse-directory'
'enter': 'tree-view:open-selected-entry'
@@ -14,5 +12,5 @@ window.keymap.bindKeys '.tree-view'
'backspace': 'tree-view:remove'
window.keymap.bindKeys '.tree-view-dialog .mini.editor'
'enter': 'tree-view:confirm'
'escape': 'tree-view:cancel'
'enter': 'core:confirm'
'escape': 'core:cancel'

View File

@@ -27,7 +27,7 @@ class TreeView extends ScrollView
@instance.serialize()
@content: (rootView) ->
@div class: 'tree-view', tabindex: -1, =>
@div class: 'tree-view tool-panel', tabindex: -1, =>
if rootView.project.getRootDirectory()
@subview 'root', new DirectoryView(directory: rootView.project.getRootDirectory(), isExpanded: true)
@@ -50,18 +50,19 @@ class TreeView extends ScrollView
@on 'click', '.entry', (e) => @entryClicked(e)
@command 'core:move-up', => @moveUp()
@command 'core:move-down', => @moveDown()
@command 'core:close', => @detatch()
@command 'tree-view:expand-directory', => @expandDirectory()
@command 'tree-view:collapse-directory', => @collapseDirectory()
@command 'tree-view:open-selected-entry', => @openSelectedEntry(true)
@command 'tree-view:move', => @moveSelectedEntry()
@command 'tree-view:add', => @add()
@command 'tree-view:remove', => @removeSelectedEntry()
@command 'tool-panel:unfocus', => @rootView.focus()
@command 'tree-view:directory-modified', =>
if @hasFocus()
@selectEntryForPath(@selectedPath) if @selectedPath
else
@selectActiveFile()
@on 'tree-view:unfocus', => @rootView.focus()
@rootView.command 'tree-view:toggle', => @toggle()
@rootView.command 'tree-view:reveal-active-file', => @revealActiveFile()
@rootView.on 'active-editor-path-change', => @selectActiveFile()
@@ -86,17 +87,20 @@ class TreeView extends ScrollView
toggle: ->
if @hasFocus()
@detach()
@rootView.focus()
else
@attach() unless @hasParent()
@focus()
if @hasParent()
@focus()
else
@attach()
attach: ->
@rootView.horizontal.prepend(this)
@focus()
detach: ->
@scrollTopAfterAttach = @scrollTop()
super
@rootView.focus()
hasFocus: ->
@is(':focus')

View File

@@ -14,11 +14,13 @@ class ChildProccess
options.stderr = @bufferLines(options.stderr) if options.stderr
$native.exec command, options, (exitStatus, stdout, stderr) ->
options.stdout?(stdout)
options.stderr?(stderr)
try
if exitStatus != 0
deferred.reject({command, exitStatus, stderr})
deferred.reject({command, exitStatus})
else
deferred.resolve(stdout, stderr)
deferred.resolve()
catch e
console.error "In ChildProccess termination callback: ", e.message
console.error e.stack

View File

@@ -1,5 +1,4 @@
# Like sands through the hourglass, so are the days of our lives.
require 'atom'
require 'window'
window.startup window.location.params.pathToOpen
window.attachRootView(window.location.params.pathToOpen)