diff --git a/spec/app/edit-session-spec.coffee b/spec/app/edit-session-spec.coffee index 3327b9f06..94611320d 100644 --- a/spec/app/edit-session-spec.coffee +++ b/spec/app/edit-session-spec.coffee @@ -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() diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index 009a6655b..f85333f99 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -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) diff --git a/src/app/pane.coffee b/src/app/pane.coffee index 39d68089e..fe96299c8 100644 --- a/src/app/pane.coffee +++ b/src/app/pane.coffee @@ -148,7 +148,7 @@ class Pane extends View @autosaveItem(item) - if item.isModified?() + if item.shouldPromptToSave?() @promptToSaveItem(item, reallyDestroyItem) else reallyDestroyItem() diff --git a/src/app/text-buffer.coffee b/src/app/text-buffer.coffee index 0d77dc914..471af8fa5 100644 --- a/src/app/text-buffer.coffee +++ b/src/app/text-buffer.coffee @@ -70,7 +70,7 @@ class Buffer path: @getPath() text: @getText() if @isModified() - hasEditors: -> @refcount > 1 + hasMultipleEditors: -> @refcount > 1 subscribeToFile: -> @file.on "contents-changed", =>