mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
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:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user