Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Don't destroy buffer when underlying file is deleted. #178

Merged
merged 6 commits into from
Jan 25, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/text-buffer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class TextBuffer
# * `load` A {Boolean}, `true` to asynchronously load the buffer from disk
# after initialization.
# * `text` The initial {String} text of the buffer.
# * `shouldDestroyOnFileDelete` A {Function} that returns a {Boolean}
# indicating whether the buffer should be destroyed if its file is
# deleted.
constructor: (params) ->
text = params if typeof params is 'string'

Expand Down Expand Up @@ -79,7 +82,7 @@ class TextBuffer
@transactCallDepth = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃憤

@digestWhenLastPersisted = params?.digestWhenLastPersisted ? false

@shouldDestroyBufferOnFileDelete = -> false
@shouldDestroyOnFileDelete = params?.shouldDestroyOnFileDelete ? -> false

@setPath(params.filePath) if params?.filePath
@load() if params?.load
Expand Down Expand Up @@ -133,9 +136,6 @@ class TextBuffer
preferredLineEnding: @preferredLineEnding
nextMarkerId: @nextMarkerId

setConfigCallbacks: (shouldDestroyBufferOnFileDelete) ->
@shouldDestroyBufferOnFileDelete = shouldDestroyBufferOnFileDelete

###
Section: Event Subscription
###
Expand Down Expand Up @@ -1477,7 +1477,7 @@ class TextBuffer
if modified
@updateCachedDiskContents()
else
if @shouldDestroyBufferOnFileDelete()
if @shouldDestroyOnFileDelete()
@destroy()
else
@unsubscribeFromFile()
Expand Down