Ensure custom title bar is always updated when document.title changes

This commit uses a new private API on Workspace that emits an event
every time the window title gets updated (e.g. as a result of an active
pane item changing, the project paths changing, etc.).

This fixes a bug that left the custom title bar with a stale
document.title under some circumstances.

Signed-off-by: Jason Rudolph <jasonrudolph@github.com>
This commit is contained in:
Antonio Scandurra
2017-06-26 16:29:31 +02:00
committed by Jason Rudolph
parent 5a8dce1175
commit 62ee913567
3 changed files with 35 additions and 12 deletions

View File

@@ -10,7 +10,7 @@ class TitleBar
@element.addEventListener 'dblclick', @dblclickHandler
@workspace.onDidChangeActivePaneItem => @updateTitle()
@workspace.onDidChangeWindowTitle => @updateTitle()
@themes.onDidChangeActiveThemes => @updateWindowSheetOffset()
@updateTitle()

View File

@@ -587,6 +587,7 @@ module.exports = class Workspace extends Model {
document.title = titleParts.join(' \u2014 ')
this.applicationDelegate.setRepresentedFilename(representedPath)
this.emitter.emit('did-change-window-title')
}
// On macOS, fades the application window's proxy icon when the current file
@@ -864,6 +865,10 @@ module.exports = class Workspace extends Model {
return this.emitter.on('did-add-text-editor', callback)
}
onDidChangeWindowTitle (callback) {
return this.emitter.on('did-change-window-title', callback)
}
/*
Section: Opening
*/