mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Window's title matches TextMate pattern of "#{basename} – #{project.path}"
This commit is contained in:
@@ -27,7 +27,7 @@ describe "RootView", ->
|
||||
expect(rootView.getEditors()[0]).toHaveClass 'active'
|
||||
expect(rootView.getActiveEditor().getPath()).toBe path
|
||||
expect(rootView.getActiveEditor().editSessions.length).toBe 1
|
||||
expect(rootView.getTitle()).toBe path
|
||||
expect(rootView.getTitle()).toBe "#{fs.base(path)} – #{rootView.project.getPath()}"
|
||||
|
||||
describe "when pathToOpen references a directory", ->
|
||||
beforeEach ->
|
||||
@@ -40,7 +40,7 @@ describe "RootView", ->
|
||||
|
||||
expect(rootView.project.getPath()).toBe path
|
||||
expect(rootView.getEditors().length).toBe 0
|
||||
expect(rootView.getTitle()).toBe path
|
||||
expect(rootView.getTitle()).toBe rootView.project.getPath()
|
||||
|
||||
describe "when called with view state data returned from a previous call to RootView.prototype.serialize", ->
|
||||
viewState = null
|
||||
@@ -114,7 +114,7 @@ describe "RootView", ->
|
||||
expect(editor3.isFocused).toBeFalsy()
|
||||
expect(editor4.isFocused).toBeFalsy()
|
||||
|
||||
expect(rootView.getTitle()).toBe editor2.getPath()
|
||||
expect(rootView.getTitle()).toBe "#{fs.base(editor2.getPath())} – #{rootView.project.getPath()}"
|
||||
|
||||
describe "when called with no pathToOpen", ->
|
||||
it "opens an empty buffer", ->
|
||||
@@ -489,19 +489,19 @@ describe "RootView", ->
|
||||
rootView.on 'active-editor-path-change', pathChangeHandler
|
||||
|
||||
editor1 = rootView.getActiveEditor()
|
||||
expect(rootView.getTitle()).toBe path
|
||||
expect(rootView.getTitle()).toBe "#{fs.base(editor1.getPath())} – #{rootView.project.getPath()}"
|
||||
|
||||
editor2 = rootView.getActiveEditor().splitLeft()
|
||||
|
||||
path = rootView.project.resolve('b')
|
||||
editor2.edit(rootView.project.buildEditSessionForPath(path))
|
||||
expect(pathChangeHandler).toHaveBeenCalled()
|
||||
expect(rootView.getTitle()).toBe rootView.project.resolve(path)
|
||||
expect(rootView.getTitle()).toBe "#{fs.base(editor2.getPath())} – #{rootView.project.getPath()}"
|
||||
|
||||
pathChangeHandler.reset()
|
||||
editor1.getBuffer().saveAs("/tmp/should-not-be-title.txt")
|
||||
expect(pathChangeHandler).not.toHaveBeenCalled()
|
||||
expect(rootView.getTitle()).toBe rootView.project.resolve(path)
|
||||
expect(rootView.getTitle()).toBe "#{fs.base(editor2.getPath())} – #{rootView.project.getPath()}"
|
||||
|
||||
it "creates a project if there isn't one yet and the buffer was previously unsaved", ->
|
||||
rootView.remove()
|
||||
@@ -535,7 +535,7 @@ describe "RootView", ->
|
||||
expect(pathChangeHandler).not.toHaveBeenCalled()
|
||||
|
||||
describe "when the last editor is removed", ->
|
||||
it "updates the title to the project path", ->
|
||||
it "updates the title to the project path", ->
|
||||
rootView.getEditors()[0].remove()
|
||||
expect(rootView.getTitle()).toBe rootView.project.getPath()
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ beforeEach ->
|
||||
|
||||
# make editor display updates synchronous
|
||||
spyOn(Editor.prototype, 'requestDisplayUpdate').andCallFake -> @updateDisplay()
|
||||
spyOn(RootView.prototype, 'setTitle').andCallFake (@title) ->
|
||||
spyOn(RootView.prototype, 'updateWindowTitle').andCallFake ->
|
||||
|
||||
afterEach ->
|
||||
delete window.rootView if window.rootView
|
||||
|
||||
@@ -47,7 +47,6 @@ class RootView extends View
|
||||
@extensions = {}
|
||||
@project = new Project(pathToOpen)
|
||||
@handleEvents()
|
||||
@setTitle()
|
||||
@loadUserConfiguration()
|
||||
|
||||
if pathToOpen
|
||||
@@ -68,7 +67,7 @@ class RootView extends View
|
||||
@getActiveEditor().focus()
|
||||
false
|
||||
else
|
||||
@setTitle(@project?.getPath())
|
||||
@setTitle(null)
|
||||
focusableChild = this.find("[tabindex=-1]:visible:first")
|
||||
if focusableChild.length
|
||||
focusableChild.focus()
|
||||
@@ -78,7 +77,10 @@ class RootView extends View
|
||||
|
||||
@on 'active-editor-path-change', (e, path) =>
|
||||
@project.setPath(path) unless @project.getRootDirectory()
|
||||
@setTitle(path)
|
||||
if path
|
||||
@setTitle(fs.base(path))
|
||||
else
|
||||
@setTitle("untitled")
|
||||
|
||||
@command 'window:increase-font-size', => @setFontSize(@getFontSize() + 1)
|
||||
@command 'window:decrease-font-size', => @setFontSize(@getFontSize() - 1)
|
||||
@@ -176,10 +178,21 @@ class RootView extends View
|
||||
keymap.bindingsForElement(document.activeElement)
|
||||
|
||||
getTitle: ->
|
||||
@title or 'untitled'
|
||||
@title or "untitled"
|
||||
|
||||
setTitle: (title='untitled') ->
|
||||
@title = document.title = title
|
||||
setTitle: (title) ->
|
||||
projectPath = @project.getPath()
|
||||
if not projectPath
|
||||
@title = "untitled"
|
||||
else if title
|
||||
@title = "#{title} – #{projectPath}"
|
||||
else
|
||||
@title = projectPath
|
||||
|
||||
@updateWindowTitle()
|
||||
|
||||
updateWindowTitle: ->
|
||||
document.title = @title
|
||||
|
||||
setShowInvisibles: (showInvisibles) ->
|
||||
return if @showInvisibles == showInvisibles
|
||||
|
||||
Reference in New Issue
Block a user