A buffer with no path sets document.title to 'untitled'

This commit is contained in:
Corey Johnson
2012-04-04 11:10:02 -07:00
parent 8d05802290
commit 2e9bef04a9
2 changed files with 10 additions and 6 deletions

View File

@@ -366,3 +366,8 @@ describe "RootView", ->
editor1.buffer.setPath("should-not-be-title.txt")
expect(document.title).toBe "second.txt"
it "sets title to 'untitled' when buffer's path is null", ->
editor = rootView.activeEditor()
editor.setBuffer(new Buffer())
expect(document.title).toBe "untitled"

View File

@@ -51,11 +51,10 @@ class RootView extends View
_.remove(@editors, editor)
@editors.push(editor)
@setTitleToActiveEditorPath()
@setTitle(editor.buffer.path)
editor.on 'buffer-path-change.root-view', (event) =>
e = $(event.target).view()
@setTitleToActiveEditorPath()
e.off '.root-view' for e in @editors
editor.on 'buffer-path-change.root-view', => @setTitle(editor.buffer.path)
editorRemoved: (editor) ->
if @panes.containsElement
@@ -66,8 +65,8 @@ class RootView extends View
else
window.close()
setTitleToActiveEditorPath: ->
document.title = @activeEditor().buffer.path
setTitle: (title='untitled') ->
document.title = title
activeEditor: ->
if @editors.length