From 2e9bef04a99eabe917ed9316640d815f29fb0d38 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 4 Apr 2012 11:10:02 -0700 Subject: [PATCH] A buffer with no path sets document.title to 'untitled' --- spec/app/root-view-spec.coffee | 5 +++++ src/app/root-view.coffee | 11 +++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/spec/app/root-view-spec.coffee b/spec/app/root-view-spec.coffee index 3a5037dd2..5b900eac1 100644 --- a/spec/app/root-view-spec.coffee +++ b/spec/app/root-view-spec.coffee @@ -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" \ No newline at end of file diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index 71b81d891..1a7729fb9 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -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