Add jsxAttributeCompletionStyle setting (#133920)

* Add jsxAttributeCompletionStyle setting

* Apply suggestions from code review

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
This commit is contained in:
Armando Aguirre
2021-09-29 16:20:23 -07:00
committed by GitHub
parent 3aaf810eee
commit 7fdc489e08
3 changed files with 46 additions and 0 deletions

View File

@@ -191,6 +191,8 @@ export default class FileConfigurationManager extends Disposable {
quotePreference: this.getQuoteStylePreference(preferencesConfig),
importModuleSpecifierPreference: getImportModuleSpecifierPreference(preferencesConfig),
importModuleSpecifierEnding: getImportModuleSpecifierEndingPreference(preferencesConfig),
// @ts-expect-error until TS 4.5 protocol update
jsxAttributeCompletionStyle: getJsxAttributeCompletionStyle(preferencesConfig),
allowTextChangesInNewFiles: document.uri.scheme === fileSchemes.file,
providePrefixAndSuffixTextForRename: preferencesConfig.get<boolean>('renameShorthandProperties', true) === false ? false : preferencesConfig.get<boolean>('useAliasesForRenames', true),
allowRenameOfImportPath: true,
@@ -263,3 +265,11 @@ function getImportModuleSpecifierEndingPreference(config: vscode.WorkspaceConfig
default: return 'auto';
}
}
function getJsxAttributeCompletionStyle(config: vscode.WorkspaceConfiguration) {
switch (config.get<string>('jsxAttributeCompletionStyle')) {
case 'braces': return 'braces';
case 'none': return 'none';
default: return 'auto';
}
}