Allow custom switch-case indentation in formatting (#53733)

This commit is contained in:
Donald33 Wang
2023-04-13 08:35:05 -07:00
committed by GitHub
parent 33ab6fd0d5
commit adcc39d2c7
8 changed files with 55 additions and 10 deletions
+1
View File
@@ -3418,6 +3418,7 @@ export interface FormatCodeSettings extends EditorSettings {
placeOpenBraceOnNewLineForControlBlocks?: boolean;
insertSpaceBeforeTypeAnnotation?: boolean;
semicolons?: SemicolonPreference;
indentSwitchCase?: boolean;
}
export interface UserPreferences {
+4 -3
View File
@@ -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:
+3 -1
View File
@@ -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
};
}