Set the project path when its first edit session is saved

This commit is contained in:
Corey Johnson & Nathan Sobo
2013-02-27 16:21:42 -07:00
committed by probablycorey
parent 9a93694a4c
commit 5291924bcc
2 changed files with 11 additions and 0 deletions

View File

@@ -20,6 +20,16 @@ describe "Project", ->
anotherEditSession.destroy()
expect(project.editSessions.length).toBe 0
describe "when an edit session is saved and the project has no path", ->
it "sets the project's path to the saved file's parent directory", ->
path = project.resolve('a')
project.setPath(undefined)
expect(project.getPath()).toBeUndefined()
editSession = project.buildEditSession()
editSession.saveAs('/tmp/atom-test-save-sets-project-path')
expect(project.getPath()).toBe '/tmp'
fs.remove('/tmp/atom-test-save-sets-project-path')
describe ".buildEditSession(path)", ->
[absolutePath, newBufferHandler, newEditSessionHandler] = []
beforeEach ->

View File

@@ -44,6 +44,7 @@ class EditSession
@buffer.retain()
@subscribe @buffer, "path-changed", =>
@project.setPath(fs.directory(@getPath())) unless @project.getPath()?
@trigger "title-changed"
@trigger "path-changed"
@subscribe @buffer, "contents-conflicted", => @trigger "contents-conflicted"