Skip to content

Commit 5e10fe2

Browse files
Mackenzie McClanemjbvz
Mackenzie McClane
authored andcommitted
Add typescript and javascript format.insertSpaceBeforeFunctionParenthesis (microsoft#21712)
* Update tsfmt.json * Update formattingProvider.ts * Update package.nls.json * Update package.json * Update package.json * Add TS version requirement to description
1 parent ef2bdc0 commit 5e10fe2

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

extensions/typescript/package.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@
164164
"default": true,
165165
"description": "%format.insertSpaceAfterFunctionKeywordForAnonymousFunctions%"
166166
},
167+
"typescript.format.insertSpaceBeforeFunctionParenthesis": {
168+
"type": "boolean",
169+
"default": false,
170+
"description": "%format.insertSpaceBeforeFunctionParenthesis%"
171+
},
167172
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": {
168173
"type": "boolean",
169174
"default": false,
@@ -229,6 +234,11 @@
229234
"default": true,
230235
"description": "%format.insertSpaceAfterFunctionKeywordForAnonymousFunctions%"
231236
},
237+
"javascript.format.insertSpaceBeforeFunctionParenthesis": {
238+
"type": "boolean",
239+
"default": false,
240+
"description": "%format.insertSpaceBeforeFunctionParenthesis%"
241+
},
232242
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": {
233243
"type": "boolean",
234244
"default": false,
@@ -357,4 +367,4 @@
357367
}
358368
]
359369
}
360-
}
370+
}

extensions/typescript/package.nls.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"format.insertSpaceBeforeAndAfterBinaryOperators": "Defines space handling after a binary operator.",
1818
"format.insertSpaceAfterKeywordsInControlFlowStatements": "Defines space handling after keywords in a control flow statement.",
1919
"format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": "Defines space handling after function keyword for anonymous functions.",
20+
"format.insertSpaceBeforeFunctionParenthesis": "Defines space handling before function argument parentheses. Requires TypeScript >= 2.1.5.",
2021
"format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": "Defines space handling after opening and before closing non empty parenthesis.",
2122
"format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": "Defines space handling after opening and before closing non empty brackets.",
2223
"format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": "Defines space handling after opening and before closing template string braces. Requires TypeScript >= 2.0.6.",
@@ -29,4 +30,4 @@
2930
"typescript.referencesCodeLens.enabled": "Enable/disable references CodeLens.",
3031
"typescript.implementationsCodeLens.enabled": "Enable/disable implementations CodeLens.",
3132
"typescript.selectTypeScriptVersion.title": "Select TypeScript Version"
32-
}
33+
}

extensions/typescript/src/features/formattingProvider.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ interface Configuration {
2121
insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
2222
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
2323
insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: boolean;
24+
insertSpaceBeforeFunctionParenthesis: boolean;
2425
placeOpenBraceOnNewLineForFunctions: boolean;
2526
placeOpenBraceOnNewLineForControlBlocks: boolean;
2627

@@ -33,6 +34,7 @@ namespace Configuration {
3334
export const insertSpaceBeforeAndAfterBinaryOperators: string = 'insertSpaceBeforeAndAfterBinaryOperators';
3435
export const insertSpaceAfterKeywordsInControlFlowStatements: string = 'insertSpaceAfterKeywordsInControlFlowStatements';
3536
export const insertSpaceAfterFunctionKeywordForAnonymousFunctions: string = 'insertSpaceAfterFunctionKeywordForAnonymousFunctions';
37+
export const insertSpaceBeforeFunctionParenthesis: string = 'insertSpaceBeforeFunctionParenthesis';
3638
export const insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: string = 'insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis';
3739
export const insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: string = 'insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets';
3840
export const insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: string = 'insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces';
@@ -59,6 +61,7 @@ namespace Configuration {
5961
result.insertSpaceBeforeAndAfterBinaryOperators = true;
6062
result.insertSpaceAfterKeywordsInControlFlowStatements = true;
6163
result.insertSpaceAfterFunctionKeywordForAnonymousFunctions = false;
64+
result.insertSpaceBeforeFunctionParenthesis = false;
6265
result.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis = false;
6366
result.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets = false;
6467
result.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces = false;
@@ -213,6 +216,7 @@ export default class TypeScriptFormattingProvider implements DocumentRangeFormat
213216
insertSpaceBeforeAndAfterBinaryOperators: this.config.insertSpaceBeforeAndAfterBinaryOperators,
214217
insertSpaceAfterKeywordsInControlFlowStatements: this.config.insertSpaceAfterKeywordsInControlFlowStatements,
215218
insertSpaceAfterFunctionKeywordForAnonymousFunctions: this.config.insertSpaceAfterFunctionKeywordForAnonymousFunctions,
219+
insertSpaceBeforeFunctionParenthesis: this.config.insertSpaceBeforeFunctionParenthesis,
216220
insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: this.config.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis,
217221
insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: this.config.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets,
218222
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: this.config.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces,
@@ -221,4 +225,4 @@ export default class TypeScriptFormattingProvider implements DocumentRangeFormat
221225
placeOpenBraceOnNewLineForControlBlocks: this.config.placeOpenBraceOnNewLineForControlBlocks
222226
};
223227
}
224-
}
228+
}

tsfmt.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
1212
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
1313
"insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
14+
"insertSpaceBeforeFunctionParenthesis": false,
1415
"placeOpenBraceOnNewLineForFunctions": false,
1516
"placeOpenBraceOnNewLineForControlBlocks": false
16-
}
17+
}

0 commit comments

Comments
 (0)