Use atom.showSaveDialog when closing a previously-unsaved buffer

This commit is contained in:
Nathan Sobo 2012-08-30 11:03:58 -06:00
parent 8b5b7de6e0
commit 3b2b829419
2 changed files with 8 additions and 7 deletions

View File

@ -18,7 +18,7 @@ atom.sendMessageToBrowserProcess = (name, data, callbacks) ->
atom.receiveMessageFromBrowserProcess = (name, data) ->
if name is 'reply'
[messageId, callbackIndex] = data.shift()
@pendingBrowserProcessCallbacks[messageId]?[callbackIndex]?(data)
@pendingBrowserProcessCallbacks[messageId]?[callbackIndex]?(data...)
atom.open = (args...) ->
@sendMessageToBrowserProcess('open', args)

View File

@ -516,14 +516,15 @@ class Editor extends View
@removeClass 'soft-wrap'
$(window).off 'resize', @_setSoftWrapColumn
save: ->
save: (onSuccess) ->
if not @getPath()
path = Native.saveDialog()
return false if not path
@getBuffer().saveAs(path)
atom.showSaveDialog (path) =>
if path
@getBuffer().saveAs(path)
onSuccess()
else
@getBuffer().save()
true
onSuccess()
subscribeToFontSize: ->
return unless rootView = @rootView()
@ -565,7 +566,7 @@ class Editor extends View
atom.confirm(
"'#{filename}' has changes, do you want to save them?"
"Your changes will be lost if you don't save them"
"Save", (=> @save() and @destroyActiveEditSession())
"Save", (=> @save(=> @destroyActiveEditSession())),
"Cancel", null
"Don't save", (=> @destroyActiveEditSession())
)