Tell text-buffer to ask about destroying buffers for deleted files

This commit is contained in:
Ian Olsen
2017-01-19 14:11:41 -08:00
parent d3066f0e3b
commit dcbd839059
3 changed files with 9 additions and 1 deletions

View File

@@ -360,9 +360,13 @@ class Project extends Model
else
@buildBuffer(absoluteFilePath)
shouldDestroyBufferOnFileDelete: ->
atom.config.get('core.closeDeletedFileTabs')
# Still needed when deserializing a tokenized buffer
buildBufferSync: (absoluteFilePath) ->
buffer = new TextBuffer({filePath: absoluteFilePath})
buffer.setConfigCallbacks(@shouldDestroyBufferOnFileDelete) if buffer.setConfigCallbacks?
@addBuffer(buffer)
buffer.loadSync()
buffer
@@ -375,6 +379,7 @@ class Project extends Model
# Returns a {Promise} that resolves to the {TextBuffer}.
buildBuffer: (absoluteFilePath) ->
buffer = new TextBuffer({filePath: absoluteFilePath})
buffer.setConfigCallbacks(@shouldDestroyBufferOnFileDelete) if buffer.setConfigCallbacks?
@addBuffer(buffer)
buffer.load()
.then((buffer) -> buffer)

View File

@@ -107,8 +107,10 @@ class TextEditorElement extends HTMLElement
@model ? @buildModel()
buildModel: ->
newBuffer = new TextBuffer(@textContent)
newBuffer.setConfigCallbacks(-> atom.config.get('core.closeDeletedFileTabs')) if newBuffer.setConfigCallbacks?
@setModel(@workspace.buildTextEditor(
buffer: new TextBuffer(@textContent)
buffer: newBuffer
softWrapped: false
tabLength: 2
softTabs: true

View File

@@ -160,6 +160,7 @@ class TextEditor extends Model
@preferredLineLength ?= 80
@buffer ?= new TextBuffer
@buffer.setConfigCallbacks(-> atom.config.get('core.closeDeletedFileTabs')) if @buffer.setConfigCallbacks?
@tokenizedBuffer ?= new TokenizedBuffer({
grammar, tabLength, @buffer, @largeFileMode, @assert
})