mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Don't prompt to save if buffer is opened elsewhere
This corrects a regression where closing an edit session that is opened somewhere else should not prompt to save since it won't be lost if closed immediately since it is still open in another pane.
This commit is contained in:
@@ -2358,3 +2358,13 @@ describe "EditSession", ->
|
||||
editSession.joinLine()
|
||||
expect(editSession.lineForBufferRow(9)).toBe ' }; return sort(Array.apply(this, arguments)); };'
|
||||
expect(editSession.getSelectedBufferRange()).toEqual [[9, 3], [9, 49]]
|
||||
|
||||
describe ".shouldPromptToSave()", ->
|
||||
it "returns false when an edit session's buffer is in use by more than one session", ->
|
||||
expect(editSession.shouldPromptToSave()).toBeFalsy()
|
||||
buffer.setText('changed')
|
||||
expect(editSession.shouldPromptToSave()).toBeTruthy()
|
||||
editSession2 = project.buildEditSession('sample.js', autoIndent: false)
|
||||
expect(editSession.shouldPromptToSave()).toBeFalsy()
|
||||
editSession2.destroy()
|
||||
expect(editSession.shouldPromptToSave()).toBeTruthy()
|
||||
|
||||
@@ -168,7 +168,7 @@ class EditSession
|
||||
scanInBufferRange: (args...) -> @buffer.scanInRange(args...)
|
||||
backwardsScanInBufferRange: (args...) -> @buffer.backwardsScanInRange(args...)
|
||||
isModified: -> @buffer.isModified()
|
||||
hasEditors: -> @buffer.hasEditors()
|
||||
shouldPromptToSave: -> @isModified() and not @buffer.hasMultipleEditors()
|
||||
|
||||
screenPositionForBufferPosition: (bufferPosition, options) -> @displayBuffer.screenPositionForBufferPosition(bufferPosition, options)
|
||||
bufferPositionForScreenPosition: (screenPosition, options) -> @displayBuffer.bufferPositionForScreenPosition(screenPosition, options)
|
||||
|
||||
@@ -148,7 +148,7 @@ class Pane extends View
|
||||
|
||||
@autosaveItem(item)
|
||||
|
||||
if item.isModified?()
|
||||
if item.shouldPromptToSave?()
|
||||
@promptToSaveItem(item, reallyDestroyItem)
|
||||
else
|
||||
reallyDestroyItem()
|
||||
|
||||
@@ -70,7 +70,7 @@ class Buffer
|
||||
path: @getPath()
|
||||
text: @getText() if @isModified()
|
||||
|
||||
hasEditors: -> @refcount > 1
|
||||
hasMultipleEditors: -> @refcount > 1
|
||||
|
||||
subscribeToFile: ->
|
||||
@file.on "contents-changed", =>
|
||||
|
||||
Reference in New Issue
Block a user