mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
🐎 Only use String::substr for pair chars
This commit is contained in:
@@ -654,12 +654,14 @@ class DisplayBuffer extends Model
|
||||
charWidths = @getScopedCharWidths(token.scopes)
|
||||
valueIndex = 0
|
||||
while valueIndex < token.value.length
|
||||
if textUtils.isPairedCharacter(token.value, valueIndex)
|
||||
if textUtils.isPairedCharacter(value, valueIndex)
|
||||
char = value.substr(valueIndex, 2)
|
||||
valueIndex += 2
|
||||
charLength = 2
|
||||
else
|
||||
char = value[valueIndex]
|
||||
charLength = 1
|
||||
char = token.value.substr(valueIndex, charLength)
|
||||
valueIndex += charLength
|
||||
valueIndex++
|
||||
|
||||
return {top, left} if column is targetColumn
|
||||
left += charWidths[char] ? defaultCharWidth unless char is '\0'
|
||||
@@ -681,12 +683,15 @@ class DisplayBuffer extends Model
|
||||
charWidths = @getScopedCharWidths(token.scopes)
|
||||
valueIndex = 0
|
||||
while valueIndex < token.value.length
|
||||
if textUtils.isPairedCharacter(token.value, valueIndex)
|
||||
if textUtils.isPairedCharacter(value, valueIndex)
|
||||
char = value.substr(valueIndex, 2)
|
||||
valueIndex += 2
|
||||
charLength = 2
|
||||
else
|
||||
char = value[valueIndex]
|
||||
charLength = 1
|
||||
char = token.value.substr(valueIndex, charLength)
|
||||
valueIndex += charLength
|
||||
valueIndex++
|
||||
|
||||
charWidth = charWidths[char] ? defaultCharWidth
|
||||
break if targetLeft <= left + (charWidth / 2)
|
||||
left += charWidth
|
||||
|
||||
@@ -315,11 +315,13 @@ LinesComponent = React.createClass
|
||||
valueIndex = 0
|
||||
while valueIndex < value.length
|
||||
if textUtils.isPairedCharacter(value, valueIndex)
|
||||
char = value.substr(valueIndex, 2)
|
||||
valueIndex += 2
|
||||
charLength = 2
|
||||
else
|
||||
char = value[valueIndex]
|
||||
charLength = 1
|
||||
char = value.substr(valueIndex, charLength)
|
||||
valueIndex += charLength
|
||||
valueIndex++
|
||||
|
||||
continue if char is '\0'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user