Wrap at the first CJK character before the boundary

This commit is contained in:
Antonio Scandurra
2015-12-11 14:26:51 +01:00
parent 4bf86b2b9e
commit 173fbba02b
2 changed files with 19 additions and 8 deletions

View File

@@ -321,19 +321,19 @@ class TokenizedLine
return unless maxColumn?
return unless @text.length > maxColumn
if isCjkCharacter(@text[maxColumn])
# always wrap when a CJK character is at the wrap boundary
return maxColumn
else if /\s/.test(@text[maxColumn])
if /\s/.test(@text[maxColumn])
# search forward for the start of a word past the boundary
for column in [maxColumn..@text.length]
return column if /\S/.test(@text[column])
return @text.length
else if isCjkCharacter(@text[maxColumn])
maxColumn
else
# search backward for the start of the word on the boundary
for column in [maxColumn..@firstNonWhitespaceIndex]
return column + 1 if /\s/.test(@text[column])
if /\s/.test(@text[column]) or isCjkCharacter(@text[column])
return column + 1
return maxColumn