Hook TextEditorRegistry to editors created by splitting panes

This commit is contained in:
Max Brunsfeld
2016-08-03 10:58:11 -07:00
parent 62ff9f1ae0
commit 0a924a9e2f
3 changed files with 31 additions and 2 deletions

View File

@@ -124,6 +124,10 @@ export default class TextEditorRegistry {
}
maintainGrammar (editor) {
if (this.editorsWithMaintainedGrammar.has(editor)) {
return
}
this.editorsWithMaintainedGrammar.add(editor)
this.selectGrammarForEditor(editor)
this.subscriptions.add(editor.onDidChangePath(() => {
@@ -148,6 +152,10 @@ export default class TextEditorRegistry {
}
maintainConfig (editor) {
if (this.editorsWithMaintainedConfig.has(editor)) {
return
}
this.editorsWithMaintainedConfig.add(editor)
this.subscribeToSettingsForEditorScope(editor)
editor.setScopedSettingsDelegate(this.scopedSettingsDelegate)

View File

@@ -84,10 +84,12 @@ class Workspace extends Model
@openers = []
@destroyedItemURIs = []
@consumeServices(@packageManager)
@subscribeToAddedItems()
subscribeToEvents: ->
@subscribeToActiveItem()
@subscribeToFontSize()
@subscribeToAddedItems()
consumeServices: ({serviceHub}) ->
@directorySearchers = []
@@ -160,6 +162,13 @@ class Workspace extends Model
@activeItemSubscriptions.add(titleSubscription) if titleSubscription?
@activeItemSubscriptions.add(modifiedSubscription) if modifiedSubscription?
subscribeToAddedItems: ->
@onDidAddPaneItem ({item, pane, index}) =>
if item instanceof TextEditor
# @textEditorRegistry.maintainConfig(item)
# @textEditorRegistry.maintainGrammar(item)
@emitter.emit 'did-add-text-editor', {textEditor: item, pane, index}
# Updates the application's title and proxy icon based on whichever file is
# open.
updateWindowTitle: =>
@@ -383,8 +392,7 @@ class Workspace extends Model
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidAddTextEditor: (callback) ->
@onDidAddPaneItem ({item, pane, index}) ->
callback({textEditor: item, pane, index}) if item instanceof TextEditor
@emitter.on 'did-add-text-editor', callback
###
Section: Opening