mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Handle a grammar change for @softTabs
This commit is contained in:
parent
b5d253b9c5
commit
1b727c1862
@ -3833,6 +3833,23 @@ describe "TextEditor", ->
|
||||
atom.config.set('editor.tabType', 'auto')
|
||||
expect(editor.getSoftTabs()).toBe false
|
||||
|
||||
describe "when the grammar changes", ->
|
||||
coffeeEditor = null
|
||||
beforeEach ->
|
||||
atom.config.set('editor.tabType', 'hard', scopeSelector: '.source.js')
|
||||
atom.config.set('editor.tabType', 'soft', scopeSelector: '.source.coffee')
|
||||
|
||||
waitsForPromise ->
|
||||
Promise.all [
|
||||
atom.packages.activatePackage('language-coffee-script')
|
||||
atom.project.open('coffee.coffee', autoIndent: false).then (o) -> coffeeEditor = o
|
||||
]
|
||||
|
||||
it "updates based on the value chosen", ->
|
||||
expect(editor.getSoftTabs()).toBe false
|
||||
editor.setGrammar(coffeeEditor.getGrammar())
|
||||
expect(editor.getSoftTabs()).toBe true
|
||||
|
||||
describe '.getTabLength()', ->
|
||||
describe 'when scoped settings are used', ->
|
||||
coffeeEditor = null
|
||||
|
@ -94,6 +94,7 @@ class TextEditor extends Model
|
||||
marker.setProperties(preserveFolds: true)
|
||||
@addSelection(marker)
|
||||
|
||||
@subscribeToTabTypeConfig()
|
||||
@subscribeToBuffer()
|
||||
@subscribeToDisplayBuffer()
|
||||
|
||||
@ -178,9 +179,15 @@ class TextEditor extends Model
|
||||
@subscribe @displayBuffer.onDidAddDecoration (decoration) => @emit 'decoration-added', decoration
|
||||
@subscribe @displayBuffer.onDidRemoveDecoration (decoration) => @emit 'decoration-removed', decoration
|
||||
|
||||
subscribeToTabTypeConfig: ->
|
||||
@tabTypeSubscription?.dispose()
|
||||
@tabTypeSubscription = atom.config.observe 'editor.tabType', scope: @getRootScopeDescriptor(), =>
|
||||
@softTabs = @shouldUseSoftTabs(defaultValue: @softTabs)
|
||||
|
||||
destroyed: ->
|
||||
@unsubscribe() if includeDeprecatedAPIs
|
||||
@disposables.dispose()
|
||||
@tabTypeSubscription.dispose()
|
||||
selection.destroy() for selection in @getSelections()
|
||||
@buffer.release()
|
||||
@displayBuffer.destroy()
|
||||
@ -2895,6 +2902,7 @@ class TextEditor extends Model
|
||||
|
||||
handleGrammarChange: ->
|
||||
@unfoldAll()
|
||||
@subscribeToTabTypeConfig()
|
||||
@emitter.emit 'did-change-grammar', @getGrammar()
|
||||
|
||||
handleMarkerCreated: (marker) =>
|
||||
|
Loading…
Reference in New Issue
Block a user