@@ -318,13 +318,38 @@ module ts {
318
318
let hasOwnProperty = Object . prototype . hasOwnProperty ;
319
319
320
320
export function isWhiteSpace ( ch : number ) : boolean {
321
- return ch === CharacterCodes . space || ch === CharacterCodes . tab || ch === CharacterCodes . verticalTab || ch === CharacterCodes . formFeed ||
322
- ch === CharacterCodes . nonBreakingSpace || ch === CharacterCodes . ogham || ch >= CharacterCodes . enQuad && ch <= CharacterCodes . zeroWidthSpace ||
323
- ch === CharacterCodes . narrowNoBreakSpace || ch === CharacterCodes . mathematicalSpace || ch === CharacterCodes . ideographicSpace || ch === CharacterCodes . byteOrderMark ;
321
+ // Note: nextLine is in the Zs space, and should be considered to be a whitespace.
322
+ // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript.
323
+ return ch === CharacterCodes . space ||
324
+ ch === CharacterCodes . tab ||
325
+ ch === CharacterCodes . verticalTab ||
326
+ ch === CharacterCodes . formFeed ||
327
+ ch === CharacterCodes . nonBreakingSpace ||
328
+ ch === CharacterCodes . nextLine ||
329
+ ch === CharacterCodes . ogham ||
330
+ ch >= CharacterCodes . enQuad && ch <= CharacterCodes . zeroWidthSpace ||
331
+ ch === CharacterCodes . narrowNoBreakSpace ||
332
+ ch === CharacterCodes . mathematicalSpace ||
333
+ ch === CharacterCodes . ideographicSpace ||
334
+ ch === CharacterCodes . byteOrderMark ;
324
335
}
325
336
326
337
export function isLineBreak ( ch : number ) : boolean {
327
- return ch === CharacterCodes . lineFeed || ch === CharacterCodes . carriageReturn || ch === CharacterCodes . lineSeparator || ch === CharacterCodes . paragraphSeparator || ch === CharacterCodes . nextLine ;
338
+ // ES5 7.3:
339
+ // The ECMAScript line terminator characters are listed in Table 3.
340
+ // Table 3 Line Terminator Characters
341
+ // Code Unit Value Name Formal Name
342
+ // \u000A Line Feed <LF>
343
+ // \u000D Carriage Return <CR>
344
+ // \u2028 Line separator <LS>
345
+ // \u2029 Paragraph separator <PS>
346
+ // Only the characters in Table 3 are treated as line terminators. Other new line or line
347
+ // breaking characters are treated as white space but not as line terminators.
348
+
349
+ return ch === CharacterCodes . lineFeed ||
350
+ ch === CharacterCodes . carriageReturn ||
351
+ ch === CharacterCodes . lineSeparator ||
352
+ ch === CharacterCodes . paragraphSeparator ;
328
353
}
329
354
330
355
function isDigit ( ch : number ) : boolean {
0 commit comments