diff --git a/src/pane.coffee b/src/pane.coffee index 9cfe9a824..6bc7d5feb 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -427,13 +427,18 @@ class Pane extends Model @destroyItem(item) for item in @getItems() when item isnt @activeItem promptToSaveItem: (item) -> - if typeof item.getUri is 'function' and typeof item.getURI isnt 'function' - Grim.deprecate("Implement `::getURI` on pane items instead of `::getUri`") + return true unless item.shouldPromptToSave?() - return true unless (typeof item.getURI is 'function' or typeof item.getUri is 'function') and item.shouldPromptToSave?() + if typeof item.getURI is 'function' + uri = item.getURI() + else if typeof item.getUri is 'function' + deprecate("Pane items should implement `::getURI` instead of `::getUri`.") + uri = item.getUri() + else + return true chosen = atom.confirm - message: "'#{item.getTitle?() ? item.getURI?() ? item.getUri?()}' has changes, do you want to save them?" + message: "'#{item.getTitle?() ? uri}' has changes, do you want to save them?" detailedMessage: "Your changes will be lost if you close this item without saving." buttons: ["Save", "Cancel", "Don't Save"] diff --git a/src/workspace.coffee b/src/workspace.coffee index c4a5be5d0..72e91571a 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -655,18 +655,24 @@ class Workspace extends Model # Removes the item's uri from the list of potential items to reopen. itemOpened: (item) -> - if typeof item.getUri is 'function' and not typeof item.getURI is 'function' + if typeof item.getURI is 'function' + uri = item.getURI() + else if typeof item.getUri is 'function' deprecate("Pane items should implement `::getURI` instead of `::getUri`.") + uri = item.getUri() - if uri = item.getURI?() ? item.getUri?() + if uri? _.remove(@destroyedItemURIs, uri) # Adds the destroyed item's uri to the list of items to reopen. didDestroyPaneItem: ({item}) => - if typeof item.getUri is 'function' and not typeof item.getURI is 'function' + if typeof item.getURI is 'function' + uri = item.getURI() + else if typeof item.getUri is 'function' deprecate("Pane items should implement `::getURI` instead of `::getUri`.") + uri = item.getUri() - if uri = item.getURI?() ? item.getUri?() + if uri? @destroyedItemURIs.push(uri) # Called by Model superclass when destroyed