mirror of
https://github.com/atom/atom.git
synced 2026-02-14 16:45:14 -05:00
Base title updates on pane:active-item-changed events
This commit is contained in:
committed by
probablycorey
parent
3ae9c10ff5
commit
d6b85cf7e8
@@ -55,6 +55,9 @@ class EditSession
|
||||
getViewClass: ->
|
||||
require 'editor'
|
||||
|
||||
getTitle: ->
|
||||
fs.base(@getPath())
|
||||
|
||||
destroy: ->
|
||||
return if @destroyed
|
||||
@destroyed = true
|
||||
|
||||
@@ -39,12 +39,8 @@ class RootView extends View
|
||||
@subscribe $(window), 'focus', (e) =>
|
||||
@handleFocus(e) if document.activeElement is document.body
|
||||
|
||||
@on 'root-view:active-path-changed', (e, path) =>
|
||||
if path
|
||||
project.setPath(path) unless project.getRootDirectory()
|
||||
@setTitle(fs.base(path))
|
||||
else
|
||||
@setTitle("untitled")
|
||||
project.on 'path-changed', => @updateTitle()
|
||||
@on 'pane:active-item-changed', => @updateTitle()
|
||||
|
||||
@command 'window:increase-font-size', =>
|
||||
config.set("editor.fontSize", config.get("editor.fontSize") + 1)
|
||||
@@ -124,22 +120,18 @@ class RootView extends View
|
||||
if not previousActiveEditor or editor.getPath() != previousActiveEditor.getPath()
|
||||
@trigger 'root-view:active-path-changed', editor.getPath()
|
||||
|
||||
getTitle: ->
|
||||
@title or "untitled"
|
||||
|
||||
updateTitle: ->
|
||||
if projectPath = project.getPath()
|
||||
if item = @getActivePaneItem()
|
||||
@setTitle("#{item.getTitle()} - #{projectPath}")
|
||||
else
|
||||
@setTitle(projectPath)
|
||||
else
|
||||
@setTitle('untitled')
|
||||
|
||||
setTitle: (title) ->
|
||||
projectPath = project.getPath()
|
||||
if not projectPath
|
||||
@title = "untitled"
|
||||
else if title
|
||||
@title = "#{title} – #{projectPath}"
|
||||
else
|
||||
@title = projectPath
|
||||
|
||||
@updateWindowTitle()
|
||||
|
||||
updateWindowTitle: ->
|
||||
document.title = @title
|
||||
document.title = title
|
||||
|
||||
getEditors: ->
|
||||
@panes.find('.pane > .item-views > .editor').map(-> $(this).view()).toArray()
|
||||
|
||||
Reference in New Issue
Block a user