Merge remote-tracking branch 'origin/master' into cj-keymap-cleanup

This commit is contained in:
probablycorey 2013-11-15 13:53:42 -08:00
commit 02f40688e2
19 changed files with 143 additions and 240 deletions

View File

@ -16,7 +16,7 @@
"clear-cut": "0.2.0",
"coffee-script": "1.6.3",
"coffeestack": "0.6.0",
"emissary": "0.9.0",
"emissary": "0.17.0",
"first-mate": "0.5.0",
"fs-plus": "0.9.0",
"fuzzaldrin": "0.1.0",
@ -28,14 +28,14 @@
"nslog": "0.1.0",
"oniguruma": "0.24.0",
"optimist": "0.4.0",
"pathwatcher": "0.9.0",
"pathwatcher": "0.10.0",
"pegjs": "0.7.0",
"q": "0.9.7",
"scandal": "0.8.0",
"season": "0.14.0",
"semver": "1.1.4",
"space-pen": "2.0.0",
"telepath": "0.23.0",
"telepath": "0.38.0",
"temp": "0.5.0",
"underscore-plus": "0.3.0"
},

View File

@ -5,9 +5,15 @@ var path = require('path');
// Executes an array of commands one by one.
function executeCommands(commands, done, index) {
index = (index == undefined ? 0 : index);
if (index < commands.length)
safeExec(commands[index], executeCommands.bind(this, commands, done, index + 1));
else
if (index < commands.length) {
var command = commands[index];
var options = null;
if (typeof command !== 'string') {
options = command.options;
command = command.command;
}
safeExec(command, options, executeCommands.bind(this, commands, done, index + 1));
} else
done(null);
}
@ -21,8 +27,8 @@ var echoNewLine = process.platform == 'win32' ? 'echo.' : 'echo';
var commands = [
'git submodule --quiet sync',
'git submodule --quiet update --recursive --init',
joinCommands('cd vendor/apm', 'npm install --silent .'),
'npm install --silent vendor/apm',
{command: joinCommands('cd vendor/apm', 'npm install --silent .'), options: {ignoreStdout: true}},
{command: 'npm install --silent vendor/apm', options: {ignoreStdout: true}},
echoNewLine,
'node node_modules/atom-package-manager/bin/apm clean',
'node node_modules/atom-package-manager/bin/apm install --silent',

View File

@ -10,7 +10,7 @@ exports.safeExec = function(command, options, callback) {
if (!options)
options = {};
// This needed to be increase for `apm test` runs that generate tons of failures
// This needed to be increased for `apm test` runs that generate many failures
// The default is 200KB.
options.maxBuffer = 1024 * 1024;
@ -21,7 +21,8 @@ exports.safeExec = function(command, options, callback) {
callback(null);
});
child.stderr.pipe(process.stderr);
child.stdout.pipe(process.stdout);
if (!options.ignoreStdout)
child.stdout.pipe(process.stdout);
}
// Same with safeExec but call child_process.spawn instead.

View File

@ -257,7 +257,8 @@ describe "Git", ->
it "subscribes to all the serialized buffers in the project", ->
project.openSync('sample.js')
project2 = deserialize(project.serialize())
#TODO Replace with atom.replicate().project when Atom is a telepath model
project2 = atom.replicate().get('project')
buffer = project2.getBuffers()[0]
waitsFor ->

View File

@ -699,11 +699,11 @@ describe "Pane", ->
it "focuses the pane after attach only if had focus when serialized", ->
reloadContainer = ->
projectState = project.serialize()
projectReplica = atom.replicate().get('project')
containerState = container.serialize()
container.remove()
project.destroy()
window.project = deserialize(projectState)
window.project = projectReplica
container = deserialize(containerState)
pane = container.getRoot()
container.attachToDom()

View File

@ -19,7 +19,8 @@ describe "Project", ->
it "destroys unretained buffers and does not include them in the serialized state", ->
project.bufferForPathSync('a')
expect(project.getBuffers().length).toBe 1
deserializedProject = deserialize(project.serialize())
project.getState().serializeForPersistence()
deserializedProject = atom.replicate().get('project')
expect(deserializedProject.getBuffers().length).toBe 0
expect(project.getBuffers().length).toBe 0

View File

@ -20,10 +20,11 @@ describe "RootView", ->
refreshRootViewAndProject = ->
rootViewState = rootView.serialize()
projectState = project.serialize()
project.getState().serializeForPersistence()
project2 = atom.replicate().get('project')
rootView.remove()
project.destroy()
window.project = deserialize(projectState)
window.project = project2
window.rootView = deserialize(rootViewState)
rootView.attachToDom()

View File

@ -4,7 +4,7 @@ describe "Selection", ->
[buffer, editSession, selection] = []
beforeEach ->
buffer = project.buildBufferSync('sample.js')
buffer = project.bufferForPathSync('sample.js')
editSession = new EditSession(buffer: buffer, tabLength: 2)
selection = editSession.getSelection()

View File

@ -47,10 +47,8 @@ if specDirectory = atom.getLoadSettings().specDirectory
beforeEach ->
$.fx.off = true
if specProjectPath
atom.project = new Project(specProjectPath)
else
atom.project = new Project(path.join(@specDirectory, 'fixtures'))
projectPath = specProjectPath ? path.join(@specDirectory, 'fixtures')
atom.project = atom.getWindowState().set('project', new Project(path: projectPath))
window.project = atom.project
atom.keymap.keyBindings = _.clone(keyBindingsToRestore)

View File

@ -13,11 +13,11 @@ describe 'TextBuffer', ->
buffer = project.bufferForPathSync(filePath)
afterEach ->
buffer?.release()
buffer?.destroy()
describe 'constructor', ->
beforeEach ->
buffer.release()
buffer.destroy()
buffer = null
describe "when given a path", ->
@ -311,8 +311,8 @@ describe 'TextBuffer', ->
it "returns false until the buffer is fully loaded", ->
buffer.release()
filePath = temp.openSync('atom').path
buffer = new TextBuffer({project, filePath})
buffer = new TextBuffer({filePath: temp.openSync('atom').path})
project.addBuffer(buffer)
expect(buffer.isModified()).toBeFalsy()
@ -554,35 +554,6 @@ describe 'TextBuffer', ->
waitsFor ->
changeHandler.callCount > 0
describe ".getRelativePath()", ->
[filePath, newPath, bufferToChange, eventHandler] = []
beforeEach ->
filePath = path.join(__dirname, "fixtures", "atom-manipulate-me")
newPath = "#{filePath}-i-moved"
fs.writeFileSync(filePath, "")
bufferToChange = project.bufferForPathSync(filePath)
eventHandler = jasmine.createSpy('eventHandler')
bufferToChange.on 'path-changed', eventHandler
afterEach ->
bufferToChange.destroy()
fs.removeSync(filePath) if fs.existsSync(filePath)
fs.removeSync(newPath) if fs.existsSync(newPath)
it "updates when the text buffer's file is moved", ->
expect(bufferToChange.getRelativePath()).toBe('atom-manipulate-me')
jasmine.unspy(window, "setTimeout")
eventHandler.reset()
fs.moveSync(filePath, newPath)
waitsFor "buffer path change", ->
eventHandler.callCount > 0
runs ->
expect(bufferToChange.getRelativePath()).toBe('atom-manipulate-me-i-moved')
describe ".getTextInRange(range)", ->
describe "when range is empty", ->
it "returns an empty string", ->
@ -926,22 +897,28 @@ describe 'TextBuffer', ->
expect(buffer.getText()).toBe "\ninitialtexthello\n1\n2\n"
describe "serialization", ->
buffer2 = null
[buffer2, project2] = []
beforeEach ->
buffer.destroy()
filePath = temp.openSync('atom').path
fs.writeFileSync(filePath, "words")
buffer = project.bufferForPathSync(filePath)
afterEach ->
buffer2?.release()
project2?.destroy()
describe "when the serialized buffer had no unsaved changes", ->
it "loads the current contents of the file at the serialized path", ->
expect(buffer.isModified()).toBeFalsy()
state = buffer.serialize()
state.get('text').insertTextAtPoint([0, 0], 'simulate divergence of on-disk contents from serialized contents')
project2 = atom.replicate().get('project')
buffer2 = project2.getBuffers()[0]
buffer2 = deserialize(state, {project})
waitsFor ->
buffer2.cachedDiskContents
waitsForPromise ->
buffer2.load()
runs ->
expect(buffer2.isModified()).toBeFalsy()
@ -951,18 +928,11 @@ describe 'TextBuffer', ->
describe "when the serialized buffer had unsaved changes", ->
describe "when the disk contents were changed since serialization", ->
it "loads the disk contents instead of the previous unsaved state", ->
buffer.release()
filePath = temp.openSync('atom').path
fs.writeFileSync(filePath, "words")
{buffer} = project.openSync(filePath)
buffer.setText("BUFFER CHANGE")
state = buffer.serialize()
expect(state.getObject('text')).toBe 'BUFFER CHANGE'
fs.writeFileSync(filePath, "DISK CHANGE")
buffer2 = deserialize(state, {project})
project2 = atom.replicate().get('project')
buffer2 = project2.getBuffers()[0]
waitsFor ->
buffer2.cachedDiskContents
@ -976,14 +946,14 @@ describe 'TextBuffer', ->
it "restores the previous unsaved state of the buffer", ->
previousText = buffer.getText()
buffer.setText("abc")
buffer.retain()
state = buffer.serialize()
expect(state.getObject('text')).toBe 'abc'
buffer.getState().serializeForPersistence()
project2 = atom.replicate().get('project')
buffer2 = project2.getBuffers()[0]
buffer2 = deserialize(state, {project})
waitsFor ->
buffer2.cachedDiskContents
waitsForPromise ->
buffer2.load()
runs ->
expect(buffer2.getPath()).toBe(buffer.getPath())
@ -999,10 +969,10 @@ describe 'TextBuffer', ->
buffer = project.bufferForPathSync()
buffer.setText("abc")
state = buffer.serialize()
state = buffer.getState().clone()
expect(state.get('path')).toBeUndefined()
expect(state.getObject('text')).toBe 'abc'
buffer2 = deserialize(state)
buffer2 = project.addBuffer(new TextBuffer(state))
expect(buffer2.getPath()).toBeUndefined()
expect(buffer2.getText()).toBe("abc")

View File

@ -350,7 +350,7 @@ 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.bufferForPathSync 'sample-with-pairs.js'
buffer.setText """
'abc\uD835\uDF97def'
//\uD835\uDF97xyz

View File

@ -120,11 +120,10 @@ class Atom
deserializeProject: ->
Project = require './project'
state = @getWindowState()
@project = deserialize(state.get('project'))
unless @project?
@project = new Project(@getLoadSettings().initialPath)
state.set('project', @project.getState())
@project = @getWindowState('project')
unless @project instanceof Project
@project = new Project(path: @getLoadSettings().initialPath)
@setWindowState('project', @project)
deserializeRootView: ->
RootView = require './root-view'
@ -295,6 +294,7 @@ class Atom
doc = Document.deserialize(documentState) if documentState?
doc ?= Document.create()
doc.registerModelClasses(require('./text-buffer'), require('./project'))
# TODO: Remove this when everything is using telepath models
if @site?
@site.setRootDocument(doc)
@ -316,6 +316,10 @@ class Atom
else
@windowState
# Private: Returns a replicated copy of the current state.
replicate: ->
@getWindowState().replicate()
crashMainProcess: ->
remote.process.crash()

View File

@ -335,9 +335,6 @@ class EditSession
# {Delegates to: TextBuffer.getPath}
getPath: -> @buffer.getPath()
# {Delegates to: TextBuffer.getRelativePath}
getRelativePath: -> @buffer.getRelativePath()
# {Delegates to: TextBuffer.getText}
getText: -> @buffer.getText()

View File

@ -104,7 +104,7 @@ class Editor extends View
@edit(editSession)
else if @mini
@edit(new EditSession
buffer: new TextBuffer
buffer: TextBuffer.createAsRoot()
softWrap: false
tabLength: 2
softTabs: true
@ -586,8 +586,10 @@ class Editor extends View
@showIndentGuide = showIndentGuide
@resetDisplay()
# {Delegates to: TextBuffer.checkoutHead}
checkoutHead: -> @getBuffer().checkoutHead()
# Checkout the HEAD revision of this editor's file.
checkoutHead: ->
if path = @getPath()
atom.project.getRepo()?.checkoutHead(path)
# {Delegates to: EditSession.setText}
setText: (text) -> @activeEditSession.setText(text)
@ -598,9 +600,6 @@ class Editor extends View
# {Delegates to: EditSession.getPath}
getPath: -> @activeEditSession?.getPath()
# {Delegates to: EditSession.getRelativePath}
getRelativePath: -> @activeEditSession?.getRelativePath()
# {Delegates to: TextBuffer.getLineCount}
getLineCount: -> @getBuffer().getLineCount()

View File

@ -71,8 +71,7 @@ class Git
@refreshStatus()
if project?
@subscribeToBuffer(buffer) for buffer in project.getBuffers()
@subscribe project, 'buffer-created', (buffer) => @subscribeToBuffer(buffer)
@subscribe project.buffers.onEach (buffer) => @subscribeToBuffer(buffer)
# Private: Subscribes to buffer events.
subscribeToBuffer: (buffer) ->

View File

@ -5,7 +5,6 @@ _ = require 'underscore-plus'
fs = require 'fs-plus'
Q = require 'q'
telepath = require 'telepath'
{Range} = telepath
TextBuffer = require './text-buffer'
EditSession = require './edit-session'
@ -19,16 +18,12 @@ Git = require './git'
# Ultimately, a project is a git directory that's been opened. It's a collection
# of directories and files that you can operate on.
module.exports =
class Project
class Project extends telepath.Model
Emitter.includeInto(this)
@acceptsDocuments: true
@version: 1
registerDeserializer(this)
# Private:
@deserialize: (state) -> new Project(state)
@properties
buffers: []
path: null
# Public: Find the local path for the given repository URL.
@pathForRepositoryUrl: (repoUrl) ->
@ -36,10 +31,15 @@ class Project
repoName = repoName.replace(/\.git$/, '')
path.join(atom.config.get('core.projectHome'), repoName)
rootDirectory: null
editSessions: null
ignoredPathRegexes: null
openers: null
# Private: Called by telepath.
attached: ->
@openers = []
@editSessions = []
@setPath(@path)
# Private: Called by telepath.
beforePersistence: ->
@destroyUnretainedBuffers()
# Public:
registerOpener: (opener) -> @openers.push(opener)
@ -59,51 +59,10 @@ class Project
@repo.destroy()
@repo = null
# Public: Establishes a new project at a given path.
#
# path - The {String} name of the path
constructor: (pathOrState) ->
@openers = []
@editSessions = []
@buffers = []
if pathOrState instanceof telepath.Document
@state = pathOrState
if projectPath = @state.remove('path')
@setPath(projectPath)
else
@setPath(@constructor.pathForRepositoryUrl(@state.get('repoUrl')))
@state.get('buffers').each (bufferState) =>
if buffer = deserialize(bufferState, project: this)
@addBuffer(buffer, updateState: false)
else
@state = atom.site.createDocument(deserializer: @constructor.name, version: @constructor.version, buffers: [])
@setPath(pathOrState)
@state.get('buffers').on 'changed', ({index, insertedValues, removedValues, siteId}) =>
return if siteId is @state.siteId
for removedBuffer in removedValues
@removeBufferAtIndex(index, updateState: false)
for insertedBuffer, i in insertedValues
@addBufferAtIndex(deserialize(insertedBuffer, project: this), index + i, updateState: false)
# Private:
serialize: ->
state = @state.clone()
state.set('path', @getPath())
@destroyUnretainedBuffers()
state.set('buffers', buffer.serialize() for buffer in @getBuffers())
state
# Private:
destroyUnretainedBuffers: ->
buffer.destroy() for buffer in @getBuffers() when not buffer.isRetained()
# Public: ?
getState: -> @state
# Public: Returns the {Git} repository if available.
getRepo: -> @repo
@ -113,6 +72,7 @@ class Project
# Public: Sets the project's fullpath.
setPath: (projectPath) ->
@path = projectPath
@rootDirectory?.off()
@destroyRepo()
@ -125,9 +85,6 @@ class Project
else
@rootDirectory = null
if originUrl = @repo?.getOriginUrl()
@state.set('repoUrl', originUrl)
@emit "path-changed"
# Public: Returns the name of the root directory.
@ -220,20 +177,18 @@ class Project
#
# Returns an {Array} of {TextBuffer}s.
getBuffers: ->
new Array(@buffers...)
new Array(@buffers.getValues()...)
isPathModified: (filePath) ->
absoluteFilePath = @resolve(filePath)
existingBuffer = _.find @buffers, (buffer) -> buffer.getPath() == absoluteFilePath
existingBuffer?.isModified()
@findBufferForPath(@resolve(filePath))?.isModified()
findBufferForPath: (filePath) ->
_.find @buffers.getValues(), (buffer) -> buffer.getPath() == filePath
# Private: Only to be used in specs
bufferForPathSync: (filePath) ->
absoluteFilePath = @resolve(filePath)
if filePath
existingBuffer = _.find @buffers, (buffer) -> buffer.getPath() == absoluteFilePath
existingBuffer = @findBufferForPath(absoluteFilePath) if filePath
existingBuffer ? @buildBufferSync(absoluteFilePath)
# Private: Given a file path, this retrieves or creates a new {TextBuffer}.
@ -246,9 +201,7 @@ class Project
# Returns a promise that resolves to the {TextBuffer}.
bufferForPath: (filePath) ->
absoluteFilePath = @resolve(filePath)
if absoluteFilePath
existingBuffer = _.find @buffers, (buffer) -> buffer.getPath() == absoluteFilePath
existingBuffer = @findBufferForPath(absoluteFilePath) if absoluteFilePath
Q(existingBuffer ? @buildBuffer(absoluteFilePath))
# Private:
@ -257,9 +210,9 @@ class Project
# Private: DEPRECATED
buildBufferSync: (absoluteFilePath) ->
buffer = new TextBuffer({project: this, filePath: absoluteFilePath})
buffer.loadSync()
buffer = new TextBuffer({filePath: absoluteFilePath})
@addBuffer(buffer)
buffer.loadSync()
buffer
# Private: Given a file path, this sets its {TextBuffer}.
@ -269,10 +222,11 @@ class Project
#
# Returns a promise that resolves to the {TextBuffer}.
buildBuffer: (absoluteFilePath) ->
buffer = new TextBuffer({project: this, filePath: absoluteFilePath})
buffer.load().then (buffer) =>
@addBuffer(buffer)
buffer
buffer = new TextBuffer({filePath: absoluteFilePath})
@addBuffer(buffer)
buffer.load()
.then((buffer) -> buffer)
.catch(=> @removeBuffer(buffer))
# Private:
addBuffer: (buffer, options={}) ->
@ -280,9 +234,10 @@ class Project
# Private:
addBufferAtIndex: (buffer, index, options={}) ->
@buffers[index] = buffer
@state.get('buffers').insert(index, buffer.getState()) if options.updateState ? true
buffer = @buffers.insert(index, buffer)
buffer.once 'destroyed', => @removeBuffer(buffer)
@emit 'buffer-created', buffer
buffer
# Private: Removes a {TextBuffer} association from the project.
#
@ -294,7 +249,6 @@ class Project
# Private:
removeBufferAtIndex: (index, options={}) ->
[buffer] = @buffers.splice(index, 1)
@state.get('buffers')?.remove(index) if options.updateState ? true
buffer?.destroy()
# Public: Performs a search across all the files in the project.
@ -329,7 +283,7 @@ class Project
task.on 'scan:paths-searched', (numberOfPathsSearched) ->
options.onPathsSearched(numberOfPathsSearched)
for buffer in @buffers when buffer.isModified()
for buffer in @buffers.getValues() when buffer.isModified()
filePath = buffer.getPath()
matches = []
buffer.scan regex, (match) -> matches.push match
@ -346,7 +300,7 @@ class Project
replace: (regex, replacementText, filePaths, iterator) ->
deferred = Q.defer()
openPaths = (buffer.getPath() for buffer in @buffers)
openPaths = (buffer.getPath() for buffer in @buffers.getValues())
outOfProcessPaths = _.difference(filePaths, openPaths)
inProcessFinished = !openPaths.length
@ -364,7 +318,7 @@ class Project
task.on 'replace:path-replaced', iterator
for buffer in @buffers
for buffer in @buffers.getValues()
replacements = buffer.replace(regex, replacementText, iterator)
iterator({filePath: buffer.getPath(), replacements}) if replacements

View File

@ -1,32 +1,28 @@
crypto = require 'crypto'
_ = require 'underscore-plus'
{Emitter, Subscriber} = require 'emissary'
guid = require 'guid'
Q = require 'q'
{P} = require 'scandal'
telepath = require 'telepath'
_ = require 'underscore-plus'
File = require './file'
{Point, Range} = telepath
# Private: Represents the contents of a file.
#
# The `Buffer` is often associated with a {File}. However, this is not always
# the case, as a `Buffer` could be an unsaved chunk of text.
# The `TextBuffer` is often associated with a {File}. However, this is not always
# the case, as a `TextBuffer` could be an unsaved chunk of text.
module.exports =
class TextBuffer
class TextBuffer extends telepath.Model
Emitter.includeInto(this)
Subscriber.includeInto(this)
@acceptsDocuments: true
@version: 2
registerDeserializer(this)
@deserialize: (state, params) ->
buffer = new this(state, params)
buffer.load()
buffer
@properties
text: -> new telepath.String('', replicated: false)
filePath: null
relativePath: null
modifiedWhenLastPersisted: false
digestWhenLastPersisted: null
stoppedChangingDelay: 300
stoppedChangingTimeout: null
@ -36,34 +32,28 @@ class TextBuffer
file: null
refcount: 0
# Creates a new buffer.
#
# * optionsOrState - An {Object} or a telepath.Document
# + filePath - A {String} representing the file path
constructor: (optionsOrState={}, params={}) ->
if optionsOrState instanceof telepath.Document
{@project} = params
@state = optionsOrState
@id = @state.get('id')
filePath = @state.get('relativePath')
@text = @state.get('text')
@useSerializedText = @state.get('isModified') != false
else
{@project, filePath} = optionsOrState
@text = new telepath.String(initialText ? '', replicated: false)
@id = guid.create().toString()
@state = atom.site.createDocument
id: @id
deserializer: @constructor.name
version: @constructor.version
text: @text
constructor: ->
super
@loadWhenAttached = @getState()?
# Private: Called by telepath.
attached: ->
@loaded = false
@useSerializedText = @modifiedWhenLastPersisted != false
@subscribe @text, 'changed', @handleTextChange
@subscribe @text, 'marker-created', (marker) => @emit 'marker-created', marker
@subscribe @text, 'markers-updated', => @emit 'markers-updated'
@setPath(@project.resolve(filePath)) if @project
@setPath(@filePath)
@load() if @loadWhenAttached
# Private: Called by telepath.
beforePersistence: ->
@modifiedWhenLastPersisted = @isModified()
@digestWhenLastPersisted = @file?.getDigest()
loadSync: ->
@updateCachedDiskContentsSync()
@ -74,7 +64,7 @@ class TextBuffer
finishLoading: ->
@loaded = true
if @useSerializedText and @state.get('diskContentsDigest') == @file?.getDigest()
if @useSerializedText and @digestWhenLastPersisted is @file?.getDigest()
@emitModifiedStatusChanged(true)
else
@reload()
@ -92,10 +82,10 @@ class TextBuffer
destroy: ->
unless @destroyed
@cancelStoppedChangingTimeout()
@file?.off()
@unsubscribe()
@destroyed = true
@project?.removeBuffer(this)
@emit 'destroyed'
isRetained: -> @refcount > 0
@ -109,16 +99,6 @@ class TextBuffer
@destroy() unless @isRetained()
this
serialize: ->
state = @state.clone()
state.set('isModified', @isModified())
state.set('diskContentsDigest', @file.getDigest()) if @file
for marker in state.get('text').getMarkers() when marker.isRemote()
marker.destroy()
state
getState: -> @state
subscribeToFile: ->
@file.on "contents-changed", =>
@conflict = true if @isModified()
@ -140,7 +120,6 @@ class TextBuffer
@emitModifiedStatusChanged(@isModified())
@file.on "moved", =>
@state.set('relativePath', @project.relativize(@getPath()))
@emit "path-changed", this
### Public ###
@ -183,10 +162,7 @@ class TextBuffer
@file?.getPath()
getUri: ->
@getRelativePath()
getRelativePath: ->
@state.get('relativePath')
atom.project.relativize(@getPath())
# Sets the path for the file.
#
@ -202,7 +178,6 @@ class TextBuffer
else
@file = null
@state.set('relativePath', @project.relativize(path))
@emit "path-changed", this
# Retrieves the current buffer's file extension.
@ -653,12 +628,6 @@ class TextBuffer
return match[0][0] != '\t'
undefined
# Checks out the current `HEAD` revision of the file.
checkoutHead: ->
path = @getPath()
return unless path
@project.getRepo()?.checkoutHead(path)
### Internal ###
transact: (fn) -> @text.transact fn
@ -680,8 +649,11 @@ class TextBuffer
else
text
scheduleModifiedEvents: ->
cancelStoppedChangingTimeout: ->
clearTimeout(@stoppedChangingTimeout) if @stoppedChangingTimeout
scheduleModifiedEvents: ->
@cancelStoppedChangingTimeout()
stoppedChangingCallback = =>
@stoppedChangingTimeout = null
modifiedStatus = @isModified()
@ -700,7 +672,7 @@ class TextBuffer
console.log row, line, line.length
getDebugSnapshot: ->
lines = ['Buffer:']
lines = ['TextBuffer:']
for row in [0..@getLastRow()]
lines.push "#{row}: #{@lineForRow(row)}"
lines.join('\n')

View File

@ -36,7 +36,7 @@ class TokenizedBuffer
{ @buffer, tabLength } = optionsOrState
@state = atom.site.createDocument
deserializer: @constructor.name
bufferPath: @buffer.getRelativePath()
bufferPath: @buffer.getPath()
tabLength: tabLength ? atom.config.get('editor.tabLength') ? 2
@subscribe syntax, 'grammar-added grammar-updated', (grammar) =>
@ -48,7 +48,7 @@ class TokenizedBuffer
@on 'grammar-changed grammar-updated', => @resetTokenizedLines()
@subscribe @buffer, "changed", (e) => @handleBufferChange(e)
@subscribe @buffer, "path-changed", => @state.set('bufferPath', @buffer.getRelativePath())
@subscribe @buffer, "path-changed", => @state.set('bufferPath', @buffer.getPath())
@reloadGrammar()

View File

@ -69,7 +69,7 @@ window.startEditorWindow = ->
window.unloadEditorWindow = ->
return if not atom.project and not atom.rootView
windowState = atom.getWindowState()
windowState.set('project', atom.project.serialize())
windowState.set('project', atom.project)
windowState.set('syntax', atom.syntax.serialize())
windowState.set('rootView', atom.rootView.serialize())
atom.packages.deactivatePackages()