From ef21823e2a4fa98d91b6fe6b40cb6838b6b3f4d8 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Thu, 5 Apr 2012 14:11:12 -0600 Subject: [PATCH] Move ScreenLineFragment.splitTokenAt to Token.splitAt --- src/app/screen-line-fragment.coffee | 8 +------- src/app/token.coffee | 5 +++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/app/screen-line-fragment.coffee b/src/app/screen-line-fragment.coffee index 182916e79..1cf2a41f2 100644 --- a/src/app/screen-line-fragment.coffee +++ b/src/app/screen-line-fragment.coffee @@ -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 diff --git a/src/app/token.coffee b/src/app/token.coffee index 83063f04c..7710670dd 100644 --- a/src/app/token.coffee +++ b/src/app/token.coffee @@ -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)]