mirror of
https://github.com/atom/atom.git
synced 2026-02-16 01:25:13 -05:00
Resubscribe to grammar events after clearing grammar registry
This commit is contained in:
@@ -21,9 +21,15 @@ class GrammarRegistry extends FirstMate.GrammarRegistry {
|
||||
constructor ({config} = {}) {
|
||||
super({maxTokensPerLine: 100, maxLineLength: 1000})
|
||||
this.config = config
|
||||
this.subscriptions = new CompositeDisposable()
|
||||
}
|
||||
|
||||
clear () {
|
||||
super.clear()
|
||||
if (this.subscriptions) this.subscriptions.dispose()
|
||||
this.subscriptions = new CompositeDisposable()
|
||||
this.languageNameOverridesByBufferId = new Map()
|
||||
this.grammarScoresByBuffer = new Map()
|
||||
this.subscriptions = new CompositeDisposable()
|
||||
|
||||
const grammarAddedOrUpdated = this.grammarAddedOrUpdated.bind(this)
|
||||
this.onDidAddGrammar(grammarAddedOrUpdated)
|
||||
|
||||
@@ -2,7 +2,7 @@ const path = require('path')
|
||||
|
||||
const _ = require('underscore-plus')
|
||||
const fs = require('fs-plus')
|
||||
const {Emitter, Disposable} = require('event-kit')
|
||||
const {Emitter, Disposable, CompositeDisposable} = require('event-kit')
|
||||
const TextBuffer = require('text-buffer')
|
||||
const {watchPath} = require('./path-watcher')
|
||||
|
||||
@@ -37,6 +37,7 @@ class Project extends Model {
|
||||
this.watcherPromisesByPath = {}
|
||||
this.retiredBufferIDs = new Set()
|
||||
this.retiredBufferPaths = new Set()
|
||||
this.subscriptions = new CompositeDisposable()
|
||||
this.consumeServices(packageManager)
|
||||
}
|
||||
|
||||
@@ -56,6 +57,9 @@ class Project extends Model {
|
||||
this.emitter.dispose()
|
||||
this.emitter = new Emitter()
|
||||
|
||||
this.subscriptions.dispose()
|
||||
this.subscriptions = new CompositeDisposable()
|
||||
|
||||
for (let buffer of this.buffers) {
|
||||
if (buffer != null) buffer.destroy()
|
||||
}
|
||||
@@ -658,7 +662,7 @@ class Project extends Model {
|
||||
|
||||
addBuffer (buffer, options = {}) {
|
||||
this.buffers.push(buffer)
|
||||
this.grammarRegistry.maintainLanguageMode(buffer)
|
||||
this.subscriptions.add(this.grammarRegistry.maintainLanguageMode(buffer))
|
||||
this.subscribeToBuffer(buffer)
|
||||
this.emitter.emit('did-add-buffer', buffer)
|
||||
return buffer
|
||||
|
||||
Reference in New Issue
Block a user