mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Avoid spurious deprecation warnings when editor URIs are undefined
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
@@ -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"]
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user