Merge pull request #15374 from atom/ku-save-as-default-dir

Don't assign default path for `showSaveDialog` unless it exists
This commit is contained in:
Nathan Sobo
2017-08-18 06:58:29 -06:00
committed by GitHub
2 changed files with 6 additions and 5 deletions

View File

@@ -567,7 +567,7 @@ describe('Pane', () => {
confirm.andReturn(0)
const success = await pane.destroyItem(item1)
expect(showSaveDialog).toHaveBeenCalled()
expect(showSaveDialog).toHaveBeenCalledWith({})
expect(item1.saveAs).toHaveBeenCalledWith('/selected/path')
expect(pane.getItems().includes(item1)).toBe(false)
expect(item1.isDestroyed()).toBe(true)
@@ -749,7 +749,7 @@ describe('Pane', () => {
it('opens a save dialog and saves the current item as the selected path', async () => {
pane.getActiveItem().saveAs = jasmine.createSpy('saveAs')
await pane.saveActiveItem()
expect(showSaveDialog).toHaveBeenCalled()
expect(showSaveDialog).toHaveBeenCalledWith({})
expect(pane.getActiveItem().saveAs).toHaveBeenCalledWith('/selected/path')
})
})
@@ -1259,7 +1259,7 @@ describe('Pane', () => {
await pane.close()
expect(atom.applicationDelegate.confirm).toHaveBeenCalled()
expect(confirmations).toBe(2)
expect(atom.applicationDelegate.showSaveDialog).toHaveBeenCalled()
expect(atom.applicationDelegate.showSaveDialog).toHaveBeenCalledWith({})
expect(item1.save).toHaveBeenCalled()
expect(item1.saveAs).toHaveBeenCalled()
expect(pane.isDestroyed()).toBe(true)
@@ -1287,7 +1287,7 @@ describe('Pane', () => {
await pane.close()
expect(atom.applicationDelegate.confirm).toHaveBeenCalled()
expect(confirmations).toBe(3)
expect(atom.applicationDelegate.showSaveDialog).toHaveBeenCalled()
expect(atom.applicationDelegate.showSaveDialog).toHaveBeenCalledWith({})
expect(item1.save).toHaveBeenCalled()
expect(item1.saveAs).toHaveBeenCalled()
expect(pane.isDestroyed()).toBe(true)

View File

@@ -742,7 +742,8 @@ class Pane
return unless item?.saveAs?
saveOptions = item.getSaveDialogOptions?() ? {}
saveOptions.defaultPath ?= item.getPath()
itemPath = item.getPath()
saveOptions.defaultPath ?= itemPath if itemPath
newItemPath = @applicationDelegate.showSaveDialog(saveOptions)
if newItemPath
promisify -> item.saveAs(newItemPath)