mirror of
https://github.com/wassname/nvatom.git
synced 2026-06-27 16:10:36 +08:00
Delete an empty note when closing a pane
Close #18. This is against nvALT, but I think this is more intuitive way.
This commit is contained in:
@@ -47,7 +47,7 @@ module.exports =
|
||||
window.addEventListener('blur', handleBlur, true)
|
||||
@subscriptions.add new Disposable -> window.removeEventListener('blur', handleBlur, true)
|
||||
|
||||
@subscriptions.add atom.workspace.onWillDestroyPaneItem ({item}) => @autosave(item)
|
||||
@subscriptions.add atom.workspace.onWillDestroyPaneItem ({item}) => @autosave(item) unless @autodelete(item)
|
||||
|
||||
deactivate: ->
|
||||
@subscriptions.dispose()
|
||||
@@ -70,6 +70,17 @@ module.exports =
|
||||
return unless path.extname(uri) in atom.config.get('nvatom.extensions')
|
||||
paneItem?.save?()
|
||||
|
||||
autodelete: (paneItem) ->
|
||||
return false unless paneItem?.getURI?()?
|
||||
uri = paneItem.getURI()
|
||||
return false unless uri.indexOf(@rootDirectory) == 0
|
||||
return false unless path.extname(uri) in atom.config.get('nvatom.extensions')
|
||||
return false unless paneItem?.isEmpty()
|
||||
fs.unlinkSync(uri)
|
||||
noteName = uri.substring(@rootDirectory.length + 1)
|
||||
atom.notifications.addInfo("Empty note #{noteName} is deleted.")
|
||||
return true
|
||||
|
||||
autosaveAll: ->
|
||||
@autosave(paneItem) for paneItem in atom.workspace.getPaneItems()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user