Skip to content

Commit

Permalink
Add preference to disable shorthand renaming
Browse files Browse the repository at this point in the history
Fixes #68029

Use the `typescript.preferences.renameShorthandProperties` and `javascript.preferences.renameShorthandProperties` to disable shorthand property renames. Default to enabling renames
  • Loading branch information
mjbvz committed Feb 14, 2019
1 parent 617958f commit b452299
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
12 changes: 12 additions & 0 deletions extensions/typescript-language-features/package.json
Expand Up @@ -525,6 +525,18 @@
"description": "%typescript.preferences.importModuleSpecifier%",
"scope": "resource"
},
"javascript.preferences.renameShorthandProperties": {
"type": "boolean",
"default": true,
"description": "%typescript.preferences.renameShorthandProperties%",
"scope": "resource"
},
"typescript.preferences.renameShorthandProperties": {
"type": "boolean",
"default": true,
"description": "%typescript.preferences.renameShorthandProperties%",
"scope": "resource"
},
"typescript.updateImportsOnFileMove.enabled": {
"type": "string",
"enum": [
Expand Down
3 changes: 2 additions & 1 deletion extensions/typescript-language-features/package.nls.json
Expand Up @@ -69,5 +69,6 @@
"typescript.autoClosingTags": "Enable/disable automatic closing of JSX tags. Requires using TypeScript 3.0 or newer in the workspace.",
"typescript.suggest.enabled": "Enabled/disable autocomplete suggestions.",
"configuration.surveys.enabled": "Enabled/disable occasional surveys that help us improve VS Code's JavaScript and TypeScript support.",
"configuration.suggest.completeJSDocs": "Enable/disable suggestion to complete JSDoc comments."
"configuration.suggest.completeJSDocs": "Enable/disable suggestion to complete JSDoc comments.",
"typescript.preferences.renameShorthandProperties": "Enable/disable introducing aliases for object shorthand properties during renames. Requires using TypeScript 3.4 or newer in the workspace."
}
Expand Up @@ -173,15 +173,15 @@ export default class FileConfigurationManager extends Disposable {
return {};
}

const preferences = vscode.workspace.getConfiguration(
const config = vscode.workspace.getConfiguration(
isTypeScriptDocument(document) ? 'typescript.preferences' : 'javascript.preferences',
document.uri);

return {
quotePreference: this.getQuoteStylePreference(preferences),
importModuleSpecifierPreference: getImportModuleSpecifierPreference(preferences),
quotePreference: this.getQuoteStylePreference(config),
importModuleSpecifierPreference: getImportModuleSpecifierPreference(config),
allowTextChangesInNewFiles: document.uri.scheme === 'file',
providePrefixAndSuffixTextForRename: true,
providePrefixAndSuffixTextForRename: config.get<boolean>('renameShorthandProperties', true),
allowRenameOfImportPath: true,
};
}
Expand Down

0 comments on commit b452299

Please sign in to comment.