Default save as dialog to directory of active item

This commit is contained in:
Kevin Sawicki 2013-07-22 09:07:56 -07:00
parent 8e92499ebb
commit 0bb7d3ba09
4 changed files with 11 additions and 4 deletions

View File

@ -1,3 +1,4 @@
* Fixed: Save As dialog now defaults to directory path of current editor
* Fixed: Using toggle comment shortcut respects indentation level
* Fixed: Search never completing in the command panel

View File

@ -2,6 +2,7 @@ PaneContainer = require 'pane-container'
Pane = require 'pane'
{View} = require 'space-pen'
$ = require 'jquery'
{dirname} = require 'path'
describe "Pane", ->
[container, view1, view2, editSession1, editSession2, pane] = []
@ -373,7 +374,7 @@ describe "Pane", ->
pane.trigger 'core:save-as'
expect(atom.showSaveDialogSync).toHaveBeenCalled()
expect(atom.showSaveDialogSync).toHaveBeenCalledWith(dirname(editSession2.getPath()))
expect(editSession2.saveAs).toHaveBeenCalledWith('/selected/path')
describe "when the current item does not have a saveAs method", ->

View File

@ -199,9 +199,10 @@ window.atom =
showSaveDialog: (callback) ->
callback(showSaveDialogSync())
showSaveDialogSync: ->
showSaveDialogSync: (defaultPath) ->
defaultPath ?= project?.getPath()
currentWindow = remote.getCurrentWindow()
dialog.showSaveDialog currentWindow, title: 'Save File'
dialog.showSaveDialog currentWindow, {title: 'Save File', defaultPath}
openDevTools: ->
remote.getCurrentWindow().openDevTools()

View File

@ -1,3 +1,4 @@
{dirname} = require 'path'
{View} = require 'space-pen'
$ = require 'jquery'
_ = require 'underscore'
@ -222,7 +223,10 @@ class Pane extends View
saveItemAs: (item, nextAction) ->
return unless item.saveAs?
path = atom.showSaveDialogSync()
itemPath = item.getUri?()
itemPath = dirname(itemPath) if itemPath
path = atom.showSaveDialogSync(itemPath)
if path
item.saveAs(path)
nextAction?()