Add insertSpaceAfterConstructor Formatting Option for TS and JS
Fixes #28206
This commit is contained in:
parent
0425eff0f0
commit
d173d8ecc1
|
@ -174,6 +174,11 @@
|
|||
"default": true,
|
||||
"description": "%format.insertSpaceAfterCommaDelimiter%"
|
||||
},
|
||||
"typescript.format.insertSpaceAfterConstructor": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "%format.insertSpaceAfterConstructor%"
|
||||
},
|
||||
"typescript.format.insertSpaceAfterSemicolonInForStatements": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
|
@ -249,6 +254,11 @@
|
|||
"default": true,
|
||||
"description": "%format.insertSpaceAfterCommaDelimiter%"
|
||||
},
|
||||
"javascript.format.insertSpaceAfterConstructor": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "%format.insertSpaceAfterConstructor%"
|
||||
},
|
||||
"javascript.format.insertSpaceAfterSemicolonInForStatements": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"typescript.format.enable": "Enable/disable default TypeScript formatter.",
|
||||
"javascript.format.enable": "Enable/disable default JavaScript formatter.",
|
||||
"format.insertSpaceAfterCommaDelimiter": "Defines space handling after a comma delimiter.",
|
||||
"format.insertSpaceAfterConstructor": "Defines space handling after the constructor keyword. Requires TypeScript >= 2.3.0.",
|
||||
"format.insertSpaceAfterSemicolonInForStatements": " Defines space handling after a semicolon in a for statement.",
|
||||
"format.insertSpaceBeforeAndAfterBinaryOperators": "Defines space handling after a binary operator.",
|
||||
"format.insertSpaceAfterKeywordsInControlFlowStatements": "Defines space handling after keywords in a control flow statement.",
|
||||
|
|
|
@ -11,6 +11,7 @@ import { ITypescriptServiceClient } from '../typescriptService';
|
|||
interface Configuration {
|
||||
enable: boolean;
|
||||
insertSpaceAfterCommaDelimiter: boolean;
|
||||
insertSpaceAfterConstructor: boolean;
|
||||
insertSpaceAfterSemicolonInForStatements: boolean;
|
||||
insertSpaceBeforeAndAfterBinaryOperators: boolean;
|
||||
insertSpaceAfterKeywordsInControlFlowStatements: boolean;
|
||||
|
@ -23,30 +24,29 @@ interface Configuration {
|
|||
insertSpaceBeforeFunctionParenthesis: boolean;
|
||||
placeOpenBraceOnNewLineForFunctions: boolean;
|
||||
placeOpenBraceOnNewLineForControlBlocks: boolean;
|
||||
|
||||
[key: string]: boolean;
|
||||
}
|
||||
|
||||
namespace Configuration {
|
||||
export const insertSpaceAfterCommaDelimiter: string = 'insertSpaceAfterCommaDelimiter';
|
||||
export const insertSpaceAfterSemicolonInForStatements: string = 'insertSpaceAfterSemicolonInForStatements';
|
||||
export const insertSpaceBeforeAndAfterBinaryOperators: string = 'insertSpaceBeforeAndAfterBinaryOperators';
|
||||
export const insertSpaceAfterKeywordsInControlFlowStatements: string = 'insertSpaceAfterKeywordsInControlFlowStatements';
|
||||
export const insertSpaceAfterFunctionKeywordForAnonymousFunctions: string = 'insertSpaceAfterFunctionKeywordForAnonymousFunctions';
|
||||
export const insertSpaceBeforeFunctionParenthesis: string = 'insertSpaceBeforeFunctionParenthesis';
|
||||
export const insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: string = 'insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis';
|
||||
export const insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: string = 'insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets';
|
||||
export const insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: string = 'insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces';
|
||||
export const insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: string = 'insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces';
|
||||
export const insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: string = 'insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces';
|
||||
export const placeOpenBraceOnNewLineForFunctions: string = 'placeOpenBraceOnNewLineForFunctions';
|
||||
export const placeOpenBraceOnNewLineForControlBlocks: string = 'placeOpenBraceOnNewLineForControlBlocks';
|
||||
export const insertSpaceAfterCommaDelimiter = 'insertSpaceAfterCommaDelimiter';
|
||||
export const insertSpaceAfterConstructor = 'insertSpaceAfterConstructor';
|
||||
export const insertSpaceAfterSemicolonInForStatements = 'insertSpaceAfterSemicolonInForStatements';
|
||||
export const insertSpaceBeforeAndAfterBinaryOperators = 'insertSpaceBeforeAndAfterBinaryOperators';
|
||||
export const insertSpaceAfterKeywordsInControlFlowStatements = 'insertSpaceAfterKeywordsInControlFlowStatements';
|
||||
export const insertSpaceAfterFunctionKeywordForAnonymousFunctions = 'insertSpaceAfterFunctionKeywordForAnonymousFunctions';
|
||||
export const insertSpaceBeforeFunctionParenthesis = 'insertSpaceBeforeFunctionParenthesis';
|
||||
export const insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis = 'insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis';
|
||||
export const insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets = 'insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets';
|
||||
export const insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces = 'insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces';
|
||||
export const insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces = 'insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces';
|
||||
export const insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces = 'insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces';
|
||||
export const placeOpenBraceOnNewLineForFunctions = 'placeOpenBraceOnNewLineForFunctions';
|
||||
export const placeOpenBraceOnNewLineForControlBlocks = 'placeOpenBraceOnNewLineForControlBlocks';
|
||||
|
||||
export function equals(a: Configuration, b: Configuration): boolean {
|
||||
let keys = Object.keys(a);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
if (a[key] !== b[key]) {
|
||||
if ((a as any)[key] !== (b as any)[key]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ namespace Configuration {
|
|||
let result: Configuration = Object.create(null);
|
||||
result.enable = true;
|
||||
result.insertSpaceAfterCommaDelimiter = true;
|
||||
result.insertSpaceAfterConstructor = false;
|
||||
result.insertSpaceAfterSemicolonInForStatements = true;
|
||||
result.insertSpaceBeforeAndAfterBinaryOperators = true;
|
||||
result.insertSpaceAfterKeywordsInControlFlowStatements = true;
|
||||
|
@ -213,6 +214,7 @@ export default class TypeScriptFormattingProvider implements DocumentRangeFormat
|
|||
// We can use \n here since the editor normalizes later on to its line endings.
|
||||
newLineCharacter: '\n',
|
||||
insertSpaceAfterCommaDelimiter: this.config.insertSpaceAfterCommaDelimiter,
|
||||
insertSpaceAfterConstructor: this.config.insertSpaceAfterConstructor,
|
||||
insertSpaceAfterSemicolonInForStatements: this.config.insertSpaceAfterSemicolonInForStatements,
|
||||
insertSpaceBeforeAndAfterBinaryOperators: this.config.insertSpaceBeforeAndAfterBinaryOperators,
|
||||
insertSpaceAfterKeywordsInControlFlowStatements: this.config.insertSpaceAfterKeywordsInControlFlowStatements,
|
||||
|
@ -224,7 +226,8 @@ export default class TypeScriptFormattingProvider implements DocumentRangeFormat
|
|||
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: this.config.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces,
|
||||
insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: this.config.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces,
|
||||
placeOpenBraceOnNewLineForFunctions: this.config.placeOpenBraceOnNewLineForFunctions,
|
||||
placeOpenBraceOnNewLineForControlBlocks: this.config.placeOpenBraceOnNewLineForControlBlocks
|
||||
placeOpenBraceOnNewLineForControlBlocks: this.config.placeOpenBraceOnNewLineForControlBlocks,
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue