fixes
This commit is contained in:
parent
3e59096506
commit
64e0bd4263
|
@ -1953,6 +1953,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitTabStop(hint: EmitHint, node: Node, snippet: TabStop) {
|
function emitTabStop(hint: EmitHint, node: Node, snippet: TabStop) {
|
||||||
|
// A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text.
|
||||||
Debug.assert(node.kind === SyntaxKind.EmptyStatement,
|
Debug.assert(node.kind === SyntaxKind.EmptyStatement,
|
||||||
`A tab stop cannot be attached to a node of kind ${Debug.formatSyntaxKind(node.kind)}.`);
|
`A tab stop cannot be attached to a node of kind ${Debug.formatSyntaxKind(node.kind)}.`);
|
||||||
Debug.assert(hint !== EmitHint.EmbeddedStatement,
|
Debug.assert(hint !== EmitHint.EmbeddedStatement,
|
||||||
|
|
|
@ -1052,15 +1052,6 @@ namespace ts.textChanges {
|
||||||
? "" : options.suffix);
|
? "" : options.suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFormatCodeSettingsForWriting({ options }: formatting.FormatContext, sourceFile: SourceFile): FormatCodeSettings {
|
|
||||||
const shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === SemicolonPreference.Ignore;
|
|
||||||
const shouldRemoveSemicolons = options.semicolons === SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !probablyUsesSemicolons(sourceFile);
|
|
||||||
return {
|
|
||||||
...options,
|
|
||||||
semicolons: shouldRemoveSemicolons ? SemicolonPreference.Remove : SemicolonPreference.Ignore,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Note: this may mutate `nodeIn`. */
|
/** Note: this may mutate `nodeIn`. */
|
||||||
function getFormattedTextOfNode(nodeIn: Node, sourceFile: SourceFile, pos: number, { indentation, prefix, delta }: InsertNodeOptions, newLineCharacter: string, formatContext: formatting.FormatContext, validate: ValidateNonFormattedText | undefined): string {
|
function getFormattedTextOfNode(nodeIn: Node, sourceFile: SourceFile, pos: number, { indentation, prefix, delta }: InsertNodeOptions, newLineCharacter: string, formatContext: formatting.FormatContext, validate: ValidateNonFormattedText | undefined): string {
|
||||||
const { node, text } = getNonformattedText(nodeIn, sourceFile, newLineCharacter);
|
const { node, text } = getNonformattedText(nodeIn, sourceFile, newLineCharacter);
|
||||||
|
|
|
@ -3290,5 +3290,17 @@ namespace ts {
|
||||||
: getLocaleSpecificMessage(diag);
|
: getLocaleSpecificMessage(diag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get format code settings for a code writing context (e.g. when formatting text changes or completions code).
|
||||||
|
*/
|
||||||
|
export function getFormatCodeSettingsForWriting({ options }: formatting.FormatContext, sourceFile: SourceFile): FormatCodeSettings {
|
||||||
|
const shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === SemicolonPreference.Ignore;
|
||||||
|
const shouldRemoveSemicolons = options.semicolons === SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !probablyUsesSemicolons(sourceFile);
|
||||||
|
return {
|
||||||
|
...options,
|
||||||
|
semicolons: shouldRemoveSemicolons ? SemicolonPreference.Remove : SemicolonPreference.Ignore,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue