diff --git a/spec/tokenized-buffer-spec.coffee b/spec/tokenized-buffer-spec.coffee index dd36ec316..9493271a8 100644 --- a/spec/tokenized-buffer-spec.coffee +++ b/spec/tokenized-buffer-spec.coffee @@ -1,7 +1,7 @@ TokenizedBuffer = require '../src/tokenized-buffer' {_} = require 'atom' -describe "TokenizedBuffer", -> +fdescribe "TokenizedBuffer", -> [tokenizedBuffer, buffer, changeHandler] = [] beforeEach -> @@ -350,7 +350,8 @@ describe "TokenizedBuffer", -> describe "when the buffer contains surrogate pairs", -> beforeEach -> atom.activatePackage('language-javascript', sync: true) - buffer = project.buildBufferSync 'sample-with-pairs.js', """ + buffer = project.buildBufferSync 'sample-with-pairs.js' + buffer.setText """ 'abc\uD835\uDF97def' //\uD835\uDF97xyz """ @@ -389,7 +390,8 @@ describe "TokenizedBuffer", -> atom.activatePackage('language-ruby-on-rails', sync: true) atom.activatePackage('language-ruby', sync: true) - buffer = project.bufferForPathSync(null, "
<%= User.find(2).full_name %>
") + buffer = project.bufferForPathSync() + buffer.setText "
<%= User.find(2).full_name %>
" tokenizedBuffer = new TokenizedBuffer({buffer}) tokenizedBuffer.setGrammar(syntax.selectGrammar('test.erb')) fullyTokenize(tokenizedBuffer) diff --git a/src/project.coffee b/src/project.coffee index 3c5456472..b11d5d937 100644 --- a/src/project.coffee +++ b/src/project.coffee @@ -219,13 +219,13 @@ class Project new Array(@buffers...) # Private: Only to be used in specs - bufferForPathSync: (filePath, text) -> + bufferForPathSync: (filePath) -> absoluteFilePath = @resolve(filePath) if filePath existingBuffer = _.find @buffers, (buffer) -> buffer.getPath() == absoluteFilePath - existingBuffer ? @buildBufferSync(absoluteFilePath, text) + existingBuffer ? @buildBufferSync(absoluteFilePath) # Private: Given a file path, this retrieves or creates a new {TextBuffer}. # @@ -233,23 +233,22 @@ class Project # `text` is used as the contents of the new buffer. # # filePath - A {String} representing a path. If `null`, an "Untitled" buffer is created. - # text - The {String} text to use as a buffer, if the file doesn't have any contents # # Returns a promise that resolves to the {TextBuffer}. - bufferForPath: (filePath, text) -> + bufferForPath: (filePath) -> absoluteFilePath = @resolve(filePath) if absoluteFilePath existingBuffer = _.find @buffers, (buffer) -> buffer.getPath() == absoluteFilePath - Q(existingBuffer ? @buildBuffer(absoluteFilePath, text)) + Q(existingBuffer ? @buildBuffer(absoluteFilePath)) # Private: bufferForId: (id) -> _.find @buffers, (buffer) -> buffer.id is id # Private: DEPRECATED - buildBufferSync: (absoluteFilePath, initialText) -> - buffer = new TextBuffer({project: this, filePath: absoluteFilePath, initialText}) + buildBufferSync: (absoluteFilePath) -> + buffer = new TextBuffer({project: this, filePath: absoluteFilePath}) buffer.loadSync() @addBuffer(buffer) buffer @@ -260,8 +259,8 @@ class Project # text - The {String} text to use as a buffer # # Returns a promise that resolves to the {TextBuffer}. - buildBuffer: (absoluteFilePath, initialText) -> - buffer = new TextBuffer({project: this, filePath: absoluteFilePath, initialText}) + buildBuffer: (absoluteFilePath) -> + buffer = new TextBuffer({project: this, filePath: absoluteFilePath}) buffer.load().then (buffer) => @addBuffer(buffer) buffer diff --git a/src/text-buffer.coffee b/src/text-buffer.coffee index 99fa698a7..43912dd1a 100644 --- a/src/text-buffer.coffee +++ b/src/text-buffer.coffee @@ -49,7 +49,7 @@ class TextBuffer @text = @state.get('text') @loadFromDisk = @state.get('isModified') == false else - {@project, filePath, initialText} = optionsOrState + {@project, filePath} = optionsOrState @text = site.createDocument(initialText ? '', shareStrings: true) @id = guid.create().toString() @state = site.createDocument @@ -57,7 +57,7 @@ class TextBuffer deserializer: @constructor.name version: @constructor.version text: @text - @loadFromDisk = not initialText + @loadFromDisk = true @loaded = false @subscribe @text, 'changed', @handleTextChange