From 224803c25f72765b5c7a8d909a93d76b284efb32 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 24 Feb 2015 16:06:57 -0800 Subject: [PATCH] Use the right project path for document title --- src/workspace.coffee | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/workspace.coffee b/src/workspace.coffee index f30d7534e..49f84f9b8 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -159,16 +159,24 @@ class Workspace extends Model # open. updateWindowTitle: => appName = 'Atom' - if projectPath = atom.project?.getPaths()[0] - if item = @getActivePaneItem() - document.title = "#{item.getTitle?() ? 'untitled'} - #{projectPath} - #{appName}" - atom.setRepresentedFilename(item.getPath?() ? projectPath) - else - document.title = "#{projectPath} - #{appName}" - atom.setRepresentedFilename(projectPath) + projectPaths = atom.project?.getPaths() ? [] + if item = @getActivePaneItem() + itemPath = item.getPath?() + itemTitle = item.getTitle?() + projectPath = _.find projectPaths, (projectPath) -> + itemPath is projectPath or itemPath?.startsWith(projectPath + path.sep) + itemTitle ?= "untitled" + projectPath ?= projectPaths[0] + + if item? and projectPath? + document.title = "#{itemTitle} - #{projectPath} - #{appName}" + atom.setRepresentedFilename(itemPath ? projectPath) + else if projectPath? + document.title = "#{projectPath} - #{appName}" + atom.setRepresentedFilename(projectPath) else - document.title = "untitled - #{appName}" - atom.setRepresentedFilename('') + document.title = "#{itemTitle} - #{appName}" + atom.setRepresentedFilename("") # On OS X, fades the application window's proxy icon when the current file # has been modified.