mirror of
https://github.com/atom/atom.git
synced 2026-02-09 14:15:24 -05:00
Move ScreenLineFragment.splitTokenAt to Token.splitAt
This commit is contained in:
@@ -22,7 +22,7 @@ class ScreenLineFragment
|
||||
leftTextLength = 0
|
||||
while leftTextLength < column
|
||||
if leftTextLength + rightTokens[0].value.length > column
|
||||
rightTokens[0..0] = @splitTokenAt(rightTokens[0], column - leftTextLength)
|
||||
rightTokens[0..0] = rightTokens[0].splitAt(column - leftTextLength)
|
||||
nextToken = rightTokens.shift()
|
||||
leftTextLength += nextToken.value.length
|
||||
leftTokens.push nextToken
|
||||
@@ -37,12 +37,6 @@ class ScreenLineFragment
|
||||
rightFragment = new ScreenLineFragment(rightTokens, rightText, rightScreenDelta, rightBufferDelta, {@state})
|
||||
[leftFragment, rightFragment]
|
||||
|
||||
splitTokenAt: (token, splitIndex) ->
|
||||
{ type, value } = token
|
||||
value1 = value.substring(0, splitIndex)
|
||||
value2 = value.substring(splitIndex)
|
||||
[{value: value1, type }, {value: value2, type}]
|
||||
|
||||
concat: (other) ->
|
||||
tokens = @tokens.concat(other.tokens)
|
||||
text = @text + other.text
|
||||
|
||||
@@ -8,3 +8,8 @@ class Token
|
||||
|
||||
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)]
|
||||
|
||||
Reference in New Issue
Block a user