Tab text is "untitled" if the buffer has no path

This commit is contained in:
Nathan Sobo
2012-11-20 16:37:59 -07:00
parent 423e8b9dcb
commit e76169e5a9
2 changed files with 13 additions and 4 deletions

View File

@@ -54,6 +54,12 @@ describe "Tabs", ->
expect(tabs.find('.tab').length).toBe 3
expect(tabs.find('.tab:eq(2) .file-name').text()).toBe 'two-hundred.txt'
describe "when the edit session's buffer has an undefined path", ->
it "makes the tab text 'untitled'", ->
rootView.open()
expect(tabs.find('.tab').length).toBe 3
expect(tabs.find('.tab:eq(2) .file-name').text()).toBe 'untitled'
describe "when an edit session is removed", ->
it "removes the tab for the removed edit session", ->
editor.setActiveEditSessionIndex(0)
@@ -80,6 +86,6 @@ describe "Tabs", ->
afterEach ->
fs.remove(newPath)
fit "updates the file name in the tab", ->
it "updates the file name in the tab", ->
buffer.saveAs(newPath)
expect(tabs.find('.tab:first .file-name')).toHaveText "foobar.js"

View File

@@ -4,8 +4,11 @@ module.exports =
class Tab extends View
@content: (editSession) ->
@div class: 'tab', =>
@div editSession.buffer.getBaseName(), class: 'file-name', outlet: 'fileName'
@div class: 'file-name', outlet: 'fileName'
initialize: (@editSession) ->
@editSession.on 'buffer-path-change.tab', =>
@fileName.text(@editSession.buffer.getBaseName())
@updateFileName()
@editSession.on 'buffer-path-change.tab', => @updateFileName()
updateFileName: ->
@fileName.text(@editSession.buffer.getBaseName() ? 'untitled')