Skip to content

Commit c1ea303

Browse files
author
Kanchalai Tanglertsampan
committed
wip-fixing consuming whitespace in children
1 parent 4562fd0 commit c1ea303

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/compiler/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,7 @@ namespace ts {
24572457
let indentation: number;
24582458
for (const line of lines) {
24592459
for (let i = 0; i < line.length && (indentation === undefined || i < indentation); i++) {
2460-
if (!isWhiteSpace(line.charCodeAt(i))) {
2460+
if (!isWhiteSpaceLike(line.charCodeAt(i))) {
24612461
if (indentation === undefined || i < indentation) {
24622462
indentation = i;
24632463
break;

src/compiler/scanner.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ namespace ts {
366366
return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position);
367367
}
368368

369-
export function isWhiteSpace(ch: number): boolean {
369+
export function isWhiteSpaceLike(ch: number): boolean {
370370
return isWhiteSpaceSingleLine(ch) || isLineBreak(ch);
371371
}
372372

@@ -510,7 +510,7 @@ namespace ts {
510510
break;
511511

512512
default:
513-
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch))) {
513+
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpaceLike(ch))) {
514514
pos++;
515515
continue;
516516
}
@@ -691,7 +691,7 @@ namespace ts {
691691
}
692692
break scan;
693693
default:
694-
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch))) {
694+
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpaceLike(ch))) {
695695
if (hasPendingCommentRange && isLineBreak(ch)) {
696696
pendingHasTrailingNewLine = true;
697697
}
@@ -1750,7 +1750,7 @@ namespace ts {
17501750
if (isLineBreak(char) && firstNonWhitespace === 0) {
17511751
firstNonWhitespace = -1;
17521752
}
1753-
else if (!isWhiteSpaceSingleLine(char)) {
1753+
else if (!isWhiteSpaceLike(char) && (char !== CharacterCodes.openBrace || char !== CharacterCodes.lessThan)) {
17541754
firstNonWhitespace = pos;
17551755
}
17561756
pos++;

src/services/formatting/smartIndenter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace ts.formatting {
5454
let current = position;
5555
while (current > 0) {
5656
const char = sourceFile.text.charCodeAt(current);
57-
if (!isWhiteSpace(char)) {
57+
if (!isWhiteSpaceLike(char)) {
5858
break;
5959
}
6060
current--;

src/services/textChanges.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ namespace ts.textChanges {
608608
if (force || !isTrivia(s)) {
609609
this.lastNonTriviaPosition = this.writer.getTextPos();
610610
let i = 0;
611-
while (isWhiteSpace(s.charCodeAt(s.length - i - 1))) {
611+
while (isWhiteSpaceLike(s.charCodeAt(s.length - i - 1))) {
612612
i++;
613613
}
614614
// trim trailing whitespaces

src/services/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ namespace ts {
13811381
}
13821382

13831383
export function getFirstNonSpaceCharacterPosition(text: string, position: number) {
1384-
while (isWhiteSpace(text.charCodeAt(position))) {
1384+
while (isWhiteSpaceLike(text.charCodeAt(position))) {
13851385
position += 1;
13861386
}
13871387
return position;

0 commit comments

Comments
 (0)