Store relative buffer path instead of id

This allows the tokenized buffer to be deserialized during reopening
from the pane container.

Closes #744
This commit is contained in:
Kevin Sawicki
2013-08-22 14:21:50 -07:00
parent 92a80208d3
commit f32a289193
2 changed files with 12 additions and 2 deletions

View File

@@ -109,6 +109,15 @@ describe "PaneContainer", ->
expect(container.reopenItem()).toBeFalsy()
expect(pane1.activeItem).toEqual item3
describe "when the last-closed pane item is an edit session", ->
it "reopens the edit session (regression)", ->
editSession = project.open('sample.js')
pane3.showItem(editSession)
pane3.destroyItem(editSession)
expect(container.reopenItem()).toBeTruthy()
expect(pane3.activeItem.getPath()).toBe editSession.getPath()
expect(container.reopenItem()).toBeFalsy()
describe "when there is no active pane", ->
it "attaches a new pane with the reconstructed last pane item and focuses it", ->
container.attachToDom()

View File

@@ -27,12 +27,12 @@ class TokenizedBuffer
constructor: (optionsOrState) ->
if optionsOrState instanceof telepath.Document
@state = optionsOrState
@buffer = project.bufferForId(optionsOrState.get('bufferId'))
@buffer = project.bufferForPath(optionsOrState.get('bufferPath'))
else
{ @buffer, tabLength } = optionsOrState
@state = site.createDocument
deserializer: @constructor.name
bufferId: @buffer.id
bufferPath: @buffer.getRelativePath()
tabLength: tabLength ? 2
@subscribe syntax, 'grammar-added grammar-updated', (grammar) =>
@@ -44,6 +44,7 @@ class TokenizedBuffer
@on 'grammar-changed grammar-updated', => @resetTokenizedLines()
@subscribe @buffer, "changed", (e) => @handleBufferChange(e)
@subscribe @buffer, "path-changed", => @state.set('bufferPath', @buffer.getRelativePath())
@reloadGrammar()