🎨 cjk -> CJK

This commit is contained in:
Antonio Scandurra 2015-12-11 14:28:26 +01:00
parent 173fbba02b
commit 12376039a9
3 changed files with 21 additions and 21 deletions

View File

@ -75,21 +75,21 @@ describe 'text utilities', ->
expect(textUtils.isKoreanCharacter("O")).toBe(false)
describe ".isCjkCharacter(character)", ->
describe ".isCJKCharacter(character)", ->
it "returns true when the character is either a korean, half-width or double-width character", ->
expect(textUtils.isCjkCharacter("")).toBe(true)
expect(textUtils.isCjkCharacter("")).toBe(true)
expect(textUtils.isCjkCharacter("")).toBe(true)
expect(textUtils.isCjkCharacter("")).toBe(true)
expect(textUtils.isCjkCharacter("")).toBe(true)
expect(textUtils.isCjkCharacter("")).toBe(true)
expect(textUtils.isCjkCharacter("")).toBe(true)
expect(textUtils.isCjkCharacter("")).toBe(true)
expect(textUtils.isCjkCharacter("")).toBe(true)
expect(textUtils.isCjkCharacter("")).toBe(true)
expect(textUtils.isCjkCharacter("")).toBe(true)
expect(textUtils.isCjkCharacter("")).toBe(true)
expect(textUtils.isCjkCharacter("")).toBe(true)
expect(textUtils.isCJKCharacter("")).toBe(true)
expect(textUtils.isCJKCharacter("")).toBe(true)
expect(textUtils.isCJKCharacter("")).toBe(true)
expect(textUtils.isCJKCharacter("")).toBe(true)
expect(textUtils.isCJKCharacter("")).toBe(true)
expect(textUtils.isCJKCharacter("")).toBe(true)
expect(textUtils.isCJKCharacter("")).toBe(true)
expect(textUtils.isCJKCharacter("")).toBe(true)
expect(textUtils.isCJKCharacter("")).toBe(true)
expect(textUtils.isCJKCharacter("")).toBe(true)
expect(textUtils.isCJKCharacter("")).toBe(true)
expect(textUtils.isCJKCharacter("")).toBe(true)
expect(textUtils.isCJKCharacter("")).toBe(true)
expect(textUtils.isDoubleWidthCharacter("a")).toBe(false)
expect(textUtils.isDoubleWidthCharacter("O")).toBe(false)

View File

@ -60,7 +60,7 @@ isPairedCharacter = (string, index=0) ->
isJapaneseCharacter = (charCode) ->
0x3000 <= charCode <= 0x30FF
isCjkUnifiedIdeograph = (charCode) ->
isCJKUnifiedIdeograph = (charCode) ->
0x4E00 <= charCode <= 0x9FAF
isFullWidthForm = (charCode) ->
@ -71,7 +71,7 @@ isDoubleWidthCharacter = (character) ->
charCode = character.charCodeAt(0)
isJapaneseCharacter(charCode) or
isCjkUnifiedIdeograph(charCode) or
isCJKUnifiedIdeograph(charCode) or
isFullWidthForm(charCode)
isHalfWidthCharacter = (character) ->
@ -89,7 +89,7 @@ isKoreanCharacter = (character) ->
0xA960 <= charCode <= 0xA97F or
0xD7B0 <= charCode <= 0xD7FF
isCjkCharacter = (character) ->
isCJKCharacter = (character) ->
isDoubleWidthCharacter(character) or
isHalfWidthCharacter(character) or
isKoreanCharacter(character)
@ -107,4 +107,4 @@ hasPairedCharacter = (string) ->
index++
false
module.exports = {isPairedCharacter, hasPairedCharacter, isDoubleWidthCharacter, isHalfWidthCharacter, isKoreanCharacter, isCjkCharacter}
module.exports = {isPairedCharacter, hasPairedCharacter, isDoubleWidthCharacter, isHalfWidthCharacter, isKoreanCharacter, isCJKCharacter}

View File

@ -1,5 +1,5 @@
_ = require 'underscore-plus'
{isPairedCharacter, isCjkCharacter} = require './text-utils'
{isPairedCharacter, isCJKCharacter} = require './text-utils'
Token = require './token'
{SoftTab, HardTab, PairedCharacter, SoftWrapIndent} = require './special-token-symbols'
@ -327,12 +327,12 @@ class TokenizedLine
return column if /\S/.test(@text[column])
return @text.length
else if isCjkCharacter(@text[maxColumn])
else if isCJKCharacter(@text[maxColumn])
maxColumn
else
# search backward for the start of the word on the boundary
for column in [maxColumn..@firstNonWhitespaceIndex]
if /\s/.test(@text[column]) or isCjkCharacter(@text[column])
if /\s/.test(@text[column]) or isCJKCharacter(@text[column])
return column + 1
return maxColumn