mirror of
https://github.com/atom/atom.git
synced 2026-02-05 12:15:07 -05:00
Fold placeholders needed to be real token objects so their screen / buffer deltas would be defined in ScreenLineFragment.proto.translateColumn
28 lines
829 B
CoffeeScript
28 lines
829 B
CoffeeScript
module.exports =
|
|
class Token
|
|
value: null
|
|
type: null
|
|
isAtomic: null
|
|
|
|
constructor: ({@value, @type, @isAtomic, @bufferDelta, @fold}) ->
|
|
@screenDelta = @value.length
|
|
@bufferDelta ?= @screenDelta
|
|
|
|
isEqual: (other) ->
|
|
@value == other.value and @type == other.type and !!@isAtomic == !!other.isAtomic
|
|
|
|
splitAt: (splitIndex) ->
|
|
value1 = @value.substring(0, splitIndex)
|
|
value2 = @value.substring(splitIndex)
|
|
[new Token(value: value1, type: @type), new Token(value: value2, type: @type)]
|
|
|
|
breakOutTabCharacters: (tabText) ->
|
|
for substring in @value.match(/([^\t]+|\t)/g)
|
|
if substring == '\t'
|
|
@buildTabToken(tabText)
|
|
else
|
|
new Token(value: substring, type: @type)
|
|
|
|
buildTabToken: (tabText) ->
|
|
new Token(value: tabText, type: @type, bufferDelta: 1, isAtomic: true)
|