mirror of
https://github.com/atom/atom.git
synced 2026-01-15 01:48:15 -05:00
Remove invisibles handling from TokenizedBuffer
This commit is contained in:
@@ -5837,8 +5837,7 @@ describe "TextEditor", ->
|
||||
|
||||
it "ignores invisibles even if editor.showInvisibles is true", ->
|
||||
atom.config.set('editor.showInvisibles', true)
|
||||
invisibles = editor.tokenizedLineForScreenRow(0).invisibles
|
||||
expect(invisibles).toBe(null)
|
||||
expect(editor.lineTextForScreenRow(0).indexOf(atom.config.get('editor.invisibles.eol'))).toBe(-1)
|
||||
|
||||
describe "when the editor is constructed with the grammar option set", ->
|
||||
beforeEach ->
|
||||
|
||||
@@ -39,7 +39,7 @@ class DisplayBuffer extends Model
|
||||
super
|
||||
|
||||
{
|
||||
tabLength, @editorWidthInChars, @tokenizedBuffer, buffer, ignoreInvisibles,
|
||||
tabLength, @editorWidthInChars, @tokenizedBuffer, buffer, @ignoreInvisibles,
|
||||
@largeFileMode, @config, @assert, @grammarRegistry, @packageManager
|
||||
} = params
|
||||
|
||||
@@ -47,7 +47,7 @@ class DisplayBuffer extends Model
|
||||
@disposables = new CompositeDisposable
|
||||
|
||||
@tokenizedBuffer ?= new TokenizedBuffer({
|
||||
tabLength, buffer, ignoreInvisibles, @largeFileMode, @config,
|
||||
tabLength, buffer, @largeFileMode, @config,
|
||||
@grammarRegistry, @packageManager, @assert
|
||||
})
|
||||
@buffer = @tokenizedBuffer.buffer
|
||||
@@ -101,7 +101,7 @@ class DisplayBuffer extends Model
|
||||
resetDisplayLayer: ->
|
||||
scopeDescriptor = @getRootScopeDescriptor()
|
||||
invisibles =
|
||||
if @config.get('editor.showInvisibles', scope: scopeDescriptor)
|
||||
if @config.get('editor.showInvisibles', scope: scopeDescriptor) and not @ignoreInvisibles
|
||||
@config.get('editor.invisibles', scope: scopeDescriptor)
|
||||
else
|
||||
{}
|
||||
@@ -260,7 +260,10 @@ class DisplayBuffer extends Model
|
||||
@tokenizedBuffer.setTabLength(tabLength)
|
||||
|
||||
setIgnoreInvisibles: (ignoreInvisibles) ->
|
||||
@tokenizedBuffer.setIgnoreInvisibles(ignoreInvisibles)
|
||||
return if ignoreInvisibles is @ignoreInvisibles
|
||||
|
||||
@ignoreInvisibles = ignoreInvisibles
|
||||
@resetDisplayLayer()
|
||||
|
||||
setSoftWrapped: (softWrapped) ->
|
||||
if softWrapped isnt @softWrapped
|
||||
|
||||
@@ -1055,7 +1055,7 @@ class TextEditor extends Model
|
||||
range
|
||||
).map (range) -> range.translate([insertDelta, 0])
|
||||
|
||||
# # Make sure the inserted text doesn't go into an existing fold
|
||||
# Make sure the inserted text doesn't go into an existing fold
|
||||
if fold = @displayLayer.largestFoldStartingAtBufferRow(followingBufferRow)
|
||||
rangesToRefold.push(@displayLayer.bufferRangeForFold(fold).translate([insertDelta - 1, 0]))
|
||||
@displayLayer.destroyFold(fold)
|
||||
|
||||
@@ -36,7 +36,7 @@ class TokenizedBuffer extends Model
|
||||
|
||||
constructor: (params) ->
|
||||
{
|
||||
@buffer, @tabLength, @ignoreInvisibles, @largeFileMode, @config,
|
||||
@buffer, @tabLength, @largeFileMode, @config,
|
||||
@grammarRegistry, @packageManager, @assert, grammarScopeName
|
||||
} = params
|
||||
|
||||
@@ -74,7 +74,6 @@ class TokenizedBuffer extends Model
|
||||
bufferPath: @buffer.getPath()
|
||||
bufferId: @buffer.getId()
|
||||
tabLength: @tabLength
|
||||
ignoreInvisibles: @ignoreInvisibles
|
||||
largeFileMode: @largeFileMode
|
||||
}
|
||||
state.grammarScopeName = @grammar?.scopeName unless @buffer.getPath()
|
||||
@@ -128,11 +127,6 @@ class TokenizedBuffer extends Model
|
||||
@configSubscriptions.add @config.onDidChange 'editor.tabLength', scopeOptions, ({newValue}) =>
|
||||
@configSettings.tabLength = newValue
|
||||
@retokenizeLines()
|
||||
['invisibles', 'showInvisibles'].forEach (key) =>
|
||||
@configSubscriptions.add @config.onDidChange "editor.#{key}", scopeOptions, ({newValue}) =>
|
||||
oldInvisibles = @getInvisiblesToShow()
|
||||
@configSettings[key] = newValue
|
||||
@retokenizeLines() unless _.isEqual(@getInvisiblesToShow(), oldInvisibles)
|
||||
@disposables.add(@configSubscriptions)
|
||||
|
||||
@retokenizeLines()
|
||||
@@ -175,12 +169,6 @@ class TokenizedBuffer extends Model
|
||||
@tabLength = tabLength
|
||||
@retokenizeLines()
|
||||
|
||||
setIgnoreInvisibles: (ignoreInvisibles) ->
|
||||
if ignoreInvisibles isnt @ignoreInvisibles
|
||||
@ignoreInvisibles = ignoreInvisibles
|
||||
if @configSettings.showInvisibles and @configSettings.invisibles?
|
||||
@retokenizeLines()
|
||||
|
||||
tokenizeInBackground: ->
|
||||
return if not @visible or @pendingChunk or not @isAlive()
|
||||
|
||||
@@ -362,7 +350,7 @@ class TokenizedBuffer extends Model
|
||||
tabLength = @getTabLength()
|
||||
indentLevel = @indentLevelForRow(row)
|
||||
lineEnding = @buffer.lineEndingForRow(row)
|
||||
new TokenizedLine({openScopes, text, tags, tabLength, indentLevel, invisibles: @getInvisiblesToShow(), lineEnding, @tokenIterator})
|
||||
new TokenizedLine({openScopes, text, tags, tabLength, indentLevel, lineEnding, @tokenIterator})
|
||||
|
||||
buildTokenizedLineForRow: (row, ruleStack, openScopes) ->
|
||||
@buildTokenizedLineForRowWithText(row, @buffer.lineForRow(row), ruleStack, openScopes)
|
||||
@@ -372,13 +360,7 @@ class TokenizedBuffer extends Model
|
||||
tabLength = @getTabLength()
|
||||
indentLevel = @indentLevelForRow(row)
|
||||
{tags, ruleStack} = @grammar.tokenizeLine(text, ruleStack, row is 0, false)
|
||||
new TokenizedLine({openScopes, text, tags, ruleStack, tabLength, lineEnding, indentLevel, invisibles: @getInvisiblesToShow(), @tokenIterator})
|
||||
|
||||
getInvisiblesToShow: ->
|
||||
if @configSettings.showInvisibles and not @ignoreInvisibles
|
||||
@configSettings.invisibles
|
||||
else
|
||||
null
|
||||
new TokenizedLine({openScopes, text, tags, ruleStack, tabLength, lineEnding, indentLevel, @tokenIterator})
|
||||
|
||||
tokenizedLineForRow: (bufferRow) ->
|
||||
if 0 <= bufferRow < @tokenizedLines.length
|
||||
|
||||
Reference in New Issue
Block a user