mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Always return Disposable from maintain{Config,Grammar}
This commit is contained in:
parent
6064602c80
commit
e6cac10a23
@ -125,6 +125,25 @@ describe('TextEditorRegistry', function () {
|
||||
expect(editor.getGrammar().name).toBe('Null Grammar')
|
||||
expect(retainedEditorCount(registry)).toBe(0)
|
||||
})
|
||||
|
||||
describe('when called twice with a given editor', function () {
|
||||
it('does nothing the second time', async function () {
|
||||
await atom.packages.activatePackage('language-javascript')
|
||||
const disposable1 = registry.maintainGrammar(editor)
|
||||
const disposable2 = registry.maintainGrammar(editor)
|
||||
|
||||
editor.getBuffer().setPath('test.js')
|
||||
expect(editor.getGrammar().name).toBe('JavaScript')
|
||||
|
||||
disposable2.dispose()
|
||||
editor.getBuffer().setPath('test.txt')
|
||||
expect(editor.getGrammar().name).toBe('Null Grammar')
|
||||
|
||||
disposable1.dispose()
|
||||
editor.getBuffer().setPath('test.js')
|
||||
expect(editor.getGrammar().name).toBe('Null Grammar')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('.setGrammarOverride', function () {
|
||||
@ -625,6 +644,27 @@ describe('TextEditorRegistry', function () {
|
||||
expect(delegate.getNonWordCharacters(['e.f', 'g.h'])).toBe('(){}[]')
|
||||
expect(delegate.getNonWordCharacters(['i.j'])).toBe('()')
|
||||
})
|
||||
|
||||
describe('when called twice with a given editor', function () {
|
||||
it('does nothing the second time', async function () {
|
||||
editor.update({scrollSensitivity: 50})
|
||||
|
||||
const disposable1 = registry.maintainConfig(editor)
|
||||
const disposable2 = registry.maintainConfig(editor)
|
||||
await initialPackageActivation
|
||||
|
||||
atom.config.set('editor.scrollSensitivity', 60)
|
||||
expect(editor.getScrollSensitivity()).toBe(60)
|
||||
|
||||
disposable2.dispose()
|
||||
atom.config.set('editor.scrollSensitivity', 70)
|
||||
expect(editor.getScrollSensitivity()).toBe(70)
|
||||
|
||||
disposable1.dispose()
|
||||
atom.config.set('editor.scrollSensitivity', 80)
|
||||
expect(editor.getScrollSensitivity()).toBe(70)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('serialization', function () {
|
||||
|
@ -157,7 +157,7 @@ export default class TextEditorRegistry {
|
||||
// configuration.
|
||||
maintainConfig (editor) {
|
||||
if (this.editorsWithMaintainedConfig.has(editor)) {
|
||||
return
|
||||
return new Disposable(noop)
|
||||
}
|
||||
this.editorsWithMaintainedConfig.add(editor)
|
||||
|
||||
@ -202,7 +202,7 @@ export default class TextEditorRegistry {
|
||||
// grammar.
|
||||
maintainGrammar (editor) {
|
||||
if (this.editorsWithMaintainedGrammar.has(editor)) {
|
||||
return
|
||||
return new Disposable(noop)
|
||||
}
|
||||
|
||||
this.editorsWithMaintainedGrammar.add(editor)
|
||||
@ -391,6 +391,8 @@ function shouldEditorUseSoftTabs (editor, tabType, softTabs) {
|
||||
}
|
||||
}
|
||||
|
||||
function noop () {}
|
||||
|
||||
class ScopedSettingsDelegate {
|
||||
constructor (config) {
|
||||
this.config = config
|
||||
|
Loading…
Reference in New Issue
Block a user