Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace ts {
// Literals
NumericLiteral,
StringLiteral,
JsxText,
RegularExpressionLiteral,
NoSubstitutionTemplateLiteral,
// Pseudo-literals
Expand Down Expand Up @@ -302,7 +303,6 @@ namespace ts {
JsxElement,
JsxSelfClosingElement,
JsxOpeningElement,
JsxText,
JsxClosingElement,
JsxAttribute,
JsxSpreadAttribute,
Expand Down
5 changes: 3 additions & 2 deletions src/services/formatting/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,10 +624,11 @@ namespace ts.formatting {
return inheritedIndentation;
}

if (isToken(child)) {
// JSX text shouldn't affect indenting
if (isToken(child) && child.kind !== SyntaxKind.JsxText) {
// if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules
const tokenInfo = formattingScanner.readTokenInfo(child);
Debug.assert(tokenInfo.token.end === child.end);
Debug.assert(tokenInfo.token.end === child.end, "Token end is child end");
consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child);
return inheritedIndentation;
}
Expand Down
4 changes: 2 additions & 2 deletions src/services/formatting/formattingScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace ts.formatting {
}

export function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner {
Debug.assert(scanner === undefined);
Debug.assert(scanner === undefined, "Scanner should be undefined");
scanner = sourceFile.languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner;

scanner.setText(sourceFile.text);
Expand Down Expand Up @@ -62,7 +62,7 @@ namespace ts.formatting {
};

function advance(): void {
Debug.assert(scanner !== undefined);
Debug.assert(scanner !== undefined, "Scanner should be present");

lastTokenInfo = undefined;
const isStarted = scanner.getStartPos() !== startPos;
Expand Down
2 changes: 1 addition & 1 deletion src/services/formatting/rulesMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ namespace ts.formatting {
}

private GetRuleBucketIndex(row: number, column: number): number {
Debug.assert(row <= SyntaxKind.LastKeyword && column <= SyntaxKind.LastKeyword, "Must compute formatting context from tokens");
const rulesBucketIndex = (row * this.mapRowLength) + column;
// Debug.Assert(rulesBucketIndex < this.map.Length, "Trying to access an index outside the array.");
return rulesBucketIndex;
}

Expand Down
4 changes: 2 additions & 2 deletions src/services/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ namespace ts {
return find(startNode || sourceFile);

function findRightmostToken(n: Node): Node {
if (isToken(n) || n.kind === SyntaxKind.JsxText) {
if (isToken(n)) {
return n;
}

Expand All @@ -761,7 +761,7 @@ namespace ts {
}

function find(n: Node): Node {
if (isToken(n) || n.kind === SyntaxKind.JsxText) {
if (isToken(n)) {
return n;
}

Expand Down