mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Don't use config in TokenizedBuffer
This commit is contained in:
@@ -109,7 +109,6 @@ class TextEditor extends Model
|
||||
state.buffer = state.tokenizedBuffer.buffer
|
||||
state.displayLayer = state.buffer.getDisplayLayer(state.displayLayerId) ? state.buffer.addDisplayLayer()
|
||||
state.selectionsMarkerLayer = state.displayLayer.getMarkerLayer(state.selectionsMarkerLayerId)
|
||||
state.config = atomEnvironment.config
|
||||
state.clipboard = atomEnvironment.clipboard
|
||||
state.grammarRegistry = atomEnvironment.grammars
|
||||
state.assert = atomEnvironment.assert.bind(atomEnvironment)
|
||||
@@ -125,12 +124,11 @@ class TextEditor extends Model
|
||||
{
|
||||
@softTabs, @firstVisibleScreenRow, @firstVisibleScreenColumn, initialLine, initialColumn, @tabLength,
|
||||
@softWrapped, @decorationManager, @selectionsMarkerLayer, @buffer, suppressCursorCreation,
|
||||
@mini, @placeholderText, lineNumberGutterVisible, @largeFileMode, @config, @clipboard, @grammarRegistry,
|
||||
@mini, @placeholderText, lineNumberGutterVisible, @largeFileMode, @clipboard, @grammarRegistry,
|
||||
@assert, grammar, @showInvisibles, @autoHeight, @scrollPastEnd, @editorWidthInChars,
|
||||
@tokenizedBuffer, @ignoreInvisibles, @displayLayer
|
||||
} = params
|
||||
|
||||
throw new Error("Must pass a config parameter when constructing TextEditors") unless @config?
|
||||
throw new Error("Must pass a clipboard parameter when constructing TextEditors") unless @clipboard?
|
||||
throw new Error("Must pass a grammarRegistry parameter when constructing TextEditors") unless @grammarRegistry?
|
||||
|
||||
@@ -158,7 +156,7 @@ class TextEditor extends Model
|
||||
|
||||
@buffer ?= new TextBuffer
|
||||
@tokenizedBuffer ?= new TokenizedBuffer({
|
||||
@tabLength, @buffer, @largeFileMode, @config, @grammarRegistry, @assert
|
||||
@tabLength, @buffer, @largeFileMode, @grammarRegistry, @assert
|
||||
})
|
||||
@displayLayer ?= @buffer.addDisplayLayer()
|
||||
@displayLayer.setTextDecorationLayer(@tokenizedBuffer)
|
||||
@@ -560,7 +558,7 @@ class TextEditor extends Model
|
||||
softTabs = @getSoftTabs()
|
||||
newEditor = new TextEditor({
|
||||
@buffer, selectionsMarkerLayer, @tabLength, softTabs,
|
||||
suppressCursorCreation: true, @config,
|
||||
suppressCursorCreation: true,
|
||||
@firstVisibleScreenRow, @firstVisibleScreenColumn,
|
||||
@clipboard, @grammarRegistry, @assert, displayLayer
|
||||
})
|
||||
|
||||
@@ -19,7 +19,6 @@ class TokenizedBuffer extends Model
|
||||
chunkSize: 50
|
||||
invalidRows: null
|
||||
visible: false
|
||||
configSettings: null
|
||||
changeCount: 0
|
||||
|
||||
@deserialize: (state, atomEnvironment) ->
|
||||
@@ -28,14 +27,13 @@ class TokenizedBuffer extends Model
|
||||
else
|
||||
# TODO: remove this fallback after everyone transitions to the latest version.
|
||||
state.buffer = atomEnvironment.project.bufferForPathSync(state.bufferPath)
|
||||
state.config = atomEnvironment.config
|
||||
state.grammarRegistry = atomEnvironment.grammars
|
||||
state.assert = atomEnvironment.assert
|
||||
new this(state)
|
||||
|
||||
constructor: (params) ->
|
||||
{
|
||||
@buffer, @tabLength, @largeFileMode, @config,
|
||||
@buffer, @tabLength, @largeFileMode,
|
||||
@grammarRegistry, @assert, grammarScopeName
|
||||
} = params
|
||||
|
||||
@@ -116,16 +114,6 @@ class TokenizedBuffer extends Model
|
||||
@grammarUpdateDisposable = @grammar.onDidUpdate => @retokenizeLines()
|
||||
@disposables.add(@grammarUpdateDisposable)
|
||||
|
||||
@configSettings = {tabLength: @config.get('editor.tabLength', {scope: @rootScopeDescriptor})}
|
||||
|
||||
if @configSubscriptions?
|
||||
@configSubscriptions.dispose()
|
||||
@disposables.remove(@configSubscriptions)
|
||||
@configSubscriptions = new CompositeDisposable
|
||||
@configSubscriptions.add @config.onDidChange 'editor.tabLength', {scope: @rootScopeDescriptor}, ({newValue}) =>
|
||||
@configSettings.tabLength = newValue
|
||||
@disposables.add(@configSubscriptions)
|
||||
|
||||
@retokenizeLines()
|
||||
|
||||
@emitter.emit 'did-change-grammar', grammar
|
||||
@@ -157,13 +145,9 @@ class TokenizedBuffer extends Model
|
||||
setVisible: (@visible) ->
|
||||
@tokenizeInBackground() if @visible
|
||||
|
||||
getTabLength: ->
|
||||
@tabLength ? @configSettings.tabLength
|
||||
getTabLength: -> @tabLength
|
||||
|
||||
setTabLength: (tabLength) ->
|
||||
return if tabLength is @tabLength
|
||||
|
||||
@tabLength = tabLength
|
||||
setTabLength: (@tabLength) ->
|
||||
|
||||
tokenizeInBackground: ->
|
||||
return if not @visible or @pendingChunk or not @isAlive()
|
||||
|
||||
Reference in New Issue
Block a user