diff --git a/spec/app/edit-session-spec.coffee b/spec/app/edit-session-spec.coffee index 3889dc35d..4c1bdc4a0 100644 --- a/spec/app/edit-session-spec.coffee +++ b/spec/app/edit-session-spec.coffee @@ -17,10 +17,17 @@ describe "EditSession", -> fixturesProject.destroy() describe "title", -> - it "uses the basename of the buffer's path as its title, or 'untitled' if the path is undefined", -> - expect(editSession.getTitle()).toBe 'sample.js' - buffer.setPath(undefined) - expect(editSession.getTitle()).toBe 'untitled' + describe ".getTitle()", -> + it "uses the basename of the buffer's path as its title, or 'untitled' if the path is undefined", -> + expect(editSession.getTitle()).toBe 'sample.js' + buffer.setPath(undefined) + expect(editSession.getTitle()).toBe 'untitled' + + describe ".getLongTitle()", -> + it "appends the name of the containing directory to the basename of the file", -> + expect(editSession.getLongTitle()).toBe 'sample.js - fixtures' + buffer.setPath(undefined) + expect(editSession.getLongTitle()).toBe 'untitled' it "emits 'title-changed' events when the underlying buffer path", -> titleChangedHandler = jasmine.createSpy("titleChangedHandler") diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index 2d72d39c5..f6e6b344a 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -63,6 +63,14 @@ class EditSession else 'untitled' + getLongTitle: -> + if path = @getPath() + fileName = fs.base(path) + directory = fs.base(fs.directory(path)) + "#{fileName} - #{directory}" + else + 'untitled' + destroy: -> return if @destroyed @destroyed = true