Skip to content

Commit 7fdc489

Browse files
Add jsxAttributeCompletionStyle setting (microsoft#133920)
* Add jsxAttributeCompletionStyle setting * Apply suggestions from code review Co-authored-by: Andrew Branch <[email protected]> Co-authored-by: Andrew Branch <[email protected]>
1 parent 3aaf810 commit 7fdc489

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

extensions/typescript-language-features/package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,38 @@
865865
"description": "%typescript.preferences.importModuleSpecifierEnding%",
866866
"scope": "resource"
867867
},
868+
"javascript.preferences.jsxAttributeCompletionStyle": {
869+
"type": "string",
870+
"enum": [
871+
"auto",
872+
"braces",
873+
"none"
874+
],
875+
"markdownEnumDescriptions": [
876+
"%typescript.preferences.jsxAttributeCompletionStyle.auto%",
877+
"%typescript.preferences.jsxAttributeCompletionStyle.braces%",
878+
"%typescript.preferences.jsxAttributeCompletionStyle.none%"
879+
],
880+
"default": "auto",
881+
"description": "%typescript.preferences.jsxAttributeCompletionStyle%",
882+
"scope": "resource"
883+
},
884+
"typescript.preferences.jsxAttributeCompletionStyle": {
885+
"type": "string",
886+
"enum": [
887+
"auto",
888+
"braces",
889+
"none"
890+
],
891+
"markdownEnumDescriptions": [
892+
"%typescript.preferences.jsxAttributeCompletionStyle.auto%",
893+
"%typescript.preferences.jsxAttributeCompletionStyle.braces%",
894+
"%typescript.preferences.jsxAttributeCompletionStyle.none%"
895+
],
896+
"default": "auto",
897+
"description": "%typescript.preferences.jsxAttributeCompletionStyle%",
898+
"scope": "resource"
899+
},
868900
"typescript.preferences.includePackageJsonAutoImports": {
869901
"type": "string",
870902
"enum": [

extensions/typescript-language-features/package.nls.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@
124124
"typescript.preferences.importModuleSpecifierEnding.minimal": "Shorten `./component/index.js` to `./component`.",
125125
"typescript.preferences.importModuleSpecifierEnding.index": "Shorten `./component/index.js` to `./component/index`.",
126126
"typescript.preferences.importModuleSpecifierEnding.js": "Do not shorten path endings; include the `.js` extension.",
127+
"typescript.preferences.jsxAttributeCompletionStyle": "Preferred style for JSX attribute completions.",
128+
"typescript.preferences.jsxAttributeCompletionStyle.auto": "Insert `={}` or `=""` after attribute names based on the prop type.",
129+
"typescript.preferences.jsxAttributeCompletionStyle.braces": "Insert `={}` after attribute names.",
130+
"typescript.preferences.jsxAttributeCompletionStyle.none": "Only insert attribute names.",
127131
"typescript.preferences.includePackageJsonAutoImports": "Enable/disable searching `package.json` dependencies for available auto imports.",
128132
"typescript.preferences.includePackageJsonAutoImports.auto": "Search dependencies based on estimated performance impact.",
129133
"typescript.preferences.includePackageJsonAutoImports.on": "Always search dependencies.",

extensions/typescript-language-features/src/languageFeatures/fileConfigurationManager.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ export default class FileConfigurationManager extends Disposable {
191191
quotePreference: this.getQuoteStylePreference(preferencesConfig),
192192
importModuleSpecifierPreference: getImportModuleSpecifierPreference(preferencesConfig),
193193
importModuleSpecifierEnding: getImportModuleSpecifierEndingPreference(preferencesConfig),
194+
// @ts-expect-error until TS 4.5 protocol update
195+
jsxAttributeCompletionStyle: getJsxAttributeCompletionStyle(preferencesConfig),
194196
allowTextChangesInNewFiles: document.uri.scheme === fileSchemes.file,
195197
providePrefixAndSuffixTextForRename: preferencesConfig.get<boolean>('renameShorthandProperties', true) === false ? false : preferencesConfig.get<boolean>('useAliasesForRenames', true),
196198
allowRenameOfImportPath: true,
@@ -263,3 +265,11 @@ function getImportModuleSpecifierEndingPreference(config: vscode.WorkspaceConfig
263265
default: return 'auto';
264266
}
265267
}
268+
269+
function getJsxAttributeCompletionStyle(config: vscode.WorkspaceConfiguration) {
270+
switch (config.get<string>('jsxAttributeCompletionStyle')) {
271+
case 'braces': return 'braces';
272+
case 'none': return 'none';
273+
default: return 'auto';
274+
}
275+
}

0 commit comments

Comments
 (0)