mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Allow custom switch-case indentation in formatting (#53733)
This commit is contained in:
@@ -3418,6 +3418,7 @@ export interface FormatCodeSettings extends EditorSettings {
|
||||
placeOpenBraceOnNewLineForControlBlocks?: boolean;
|
||||
insertSpaceBeforeTypeAnnotation?: boolean;
|
||||
semicolons?: SemicolonPreference;
|
||||
indentSwitchCase?: boolean;
|
||||
}
|
||||
|
||||
export interface UserPreferences {
|
||||
|
||||
@@ -653,9 +653,6 @@ export namespace SmartIndenter {
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.MappedType:
|
||||
case SyntaxKind.TupleType:
|
||||
case SyntaxKind.CaseBlock:
|
||||
case SyntaxKind.DefaultClause:
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.CallExpression:
|
||||
@@ -684,7 +681,11 @@ export namespace SmartIndenter {
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.DefaultClause:
|
||||
return true;
|
||||
case SyntaxKind.CaseBlock:
|
||||
return settings.indentSwitchCase ?? true;
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.BinaryExpression:
|
||||
|
||||
@@ -1118,6 +1118,7 @@ export interface FormatCodeSettings extends EditorSettings {
|
||||
readonly insertSpaceBeforeTypeAnnotation?: boolean;
|
||||
readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean;
|
||||
readonly semicolons?: SemicolonPreference;
|
||||
readonly indentSwitchCase?: boolean;
|
||||
}
|
||||
|
||||
export function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings {
|
||||
@@ -1142,7 +1143,8 @@ export function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatC
|
||||
placeOpenBraceOnNewLineForFunctions: false,
|
||||
placeOpenBraceOnNewLineForControlBlocks: false,
|
||||
semicolons: SemicolonPreference.Ignore,
|
||||
trimTrailingWhitespace: true
|
||||
trimTrailingWhitespace: true,
|
||||
indentSwitchCase: true
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user