mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-10 15:25:54 -06:00
wip-fixing consuming whitespace in children
This commit is contained in:
parent
4562fd089c
commit
c1ea3034d5
@ -2457,7 +2457,7 @@ namespace ts {
|
||||
let indentation: number;
|
||||
for (const line of lines) {
|
||||
for (let i = 0; i < line.length && (indentation === undefined || i < indentation); i++) {
|
||||
if (!isWhiteSpace(line.charCodeAt(i))) {
|
||||
if (!isWhiteSpaceLike(line.charCodeAt(i))) {
|
||||
if (indentation === undefined || i < indentation) {
|
||||
indentation = i;
|
||||
break;
|
||||
|
||||
@ -366,7 +366,7 @@ namespace ts {
|
||||
return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position);
|
||||
}
|
||||
|
||||
export function isWhiteSpace(ch: number): boolean {
|
||||
export function isWhiteSpaceLike(ch: number): boolean {
|
||||
return isWhiteSpaceSingleLine(ch) || isLineBreak(ch);
|
||||
}
|
||||
|
||||
@ -510,7 +510,7 @@ namespace ts {
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch))) {
|
||||
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpaceLike(ch))) {
|
||||
pos++;
|
||||
continue;
|
||||
}
|
||||
@ -691,7 +691,7 @@ namespace ts {
|
||||
}
|
||||
break scan;
|
||||
default:
|
||||
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch))) {
|
||||
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpaceLike(ch))) {
|
||||
if (hasPendingCommentRange && isLineBreak(ch)) {
|
||||
pendingHasTrailingNewLine = true;
|
||||
}
|
||||
@ -1750,7 +1750,7 @@ namespace ts {
|
||||
if (isLineBreak(char) && firstNonWhitespace === 0) {
|
||||
firstNonWhitespace = -1;
|
||||
}
|
||||
else if (!isWhiteSpaceSingleLine(char)) {
|
||||
else if (!isWhiteSpaceLike(char) && (char !== CharacterCodes.openBrace || char !== CharacterCodes.lessThan)) {
|
||||
firstNonWhitespace = pos;
|
||||
}
|
||||
pos++;
|
||||
|
||||
@ -54,7 +54,7 @@ namespace ts.formatting {
|
||||
let current = position;
|
||||
while (current > 0) {
|
||||
const char = sourceFile.text.charCodeAt(current);
|
||||
if (!isWhiteSpace(char)) {
|
||||
if (!isWhiteSpaceLike(char)) {
|
||||
break;
|
||||
}
|
||||
current--;
|
||||
|
||||
@ -608,7 +608,7 @@ namespace ts.textChanges {
|
||||
if (force || !isTrivia(s)) {
|
||||
this.lastNonTriviaPosition = this.writer.getTextPos();
|
||||
let i = 0;
|
||||
while (isWhiteSpace(s.charCodeAt(s.length - i - 1))) {
|
||||
while (isWhiteSpaceLike(s.charCodeAt(s.length - i - 1))) {
|
||||
i++;
|
||||
}
|
||||
// trim trailing whitespaces
|
||||
|
||||
@ -1381,7 +1381,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getFirstNonSpaceCharacterPosition(text: string, position: number) {
|
||||
while (isWhiteSpace(text.charCodeAt(position))) {
|
||||
while (isWhiteSpaceLike(text.charCodeAt(position))) {
|
||||
position += 1;
|
||||
}
|
||||
return position;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user