Handle changes to the tabLength setting

This commit is contained in:
Ben Ogle
2014-10-03 16:22:16 -07:00
parent 339cb02269
commit 8cd217e50a
3 changed files with 25 additions and 6 deletions

View File

@@ -485,10 +485,9 @@ class TextEditor extends Model
# Create an {TextEditor} with its initial state based on this object
copy: ->
tabLength = @getTabLength()
displayBuffer = @displayBuffer.copy()
softTabs = @getSoftTabs()
newEditor = new TextEditor({@buffer, displayBuffer, tabLength, softTabs, suppressCursorCreation: true, registerEditor: true})
newEditor = new TextEditor({@buffer, displayBuffer, @tabLength, softTabs, suppressCursorCreation: true, registerEditor: true})
for marker in @findMarkers(editorId: @id)
marker.copy(editorId: newEditor.id, preserveFolds: true)
newEditor

View File

@@ -31,10 +31,6 @@ class TokenizedBuffer extends Model
@subscribe @buffer.onDidChange (e) => @handleBufferChange(e)
@subscribe @buffer.onDidChangePath (@bufferPath) => @reloadGrammar()
# TODO: FIXME: make this work for scoped properties
@subscribe @$tabLength.changes, (tabLength) => @retokenizeLines()
@subscribe atom.config.onDidChange 'editor.tabLength', ({newValue}) => @setTabLength(newValue)
@reloadGrammar()
serializeParams: ->
@@ -83,6 +79,12 @@ class TokenizedBuffer extends Model
@currentGrammarScore = score ? grammar.getScore(@buffer.getPath(), @buffer.getText())
@subscribe @grammar.onDidUpdate => @retokenizeLines()
@retokenizeLines()
@grammarTabLengthSubscription?.dispose()
@grammarTabLengthSubscription = atom.config.onDidChange @grammarScopeDescriptor, 'editor.tabLength', =>
@retokenizeLines()
@subscribe @grammarTabLengthSubscription
@emit 'grammar-changed', grammar
@emitter.emit 'did-change-grammar', grammar