Skip to content

Commit

Permalink
Tweak whitespaceAroundPipe settings migration logic to do it only once (
Browse files Browse the repository at this point in the history
#2703)

* Tweak whitespaceAroundPipe settings migration logic to do it only once

* refactor

Co-authored-by: Christoph Bergmeister <christoph.bergmeister@bjss.com>
  • Loading branch information
bergmeister and Christoph Bergmeister authored May 18, 2020
1 parent 3256d4e commit 252a2c5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,12 @@ export class SessionManager implements Middleware {
private async migrateWhitespaceAroundPipeSetting() {
const configuration = vscode.workspace.getConfiguration(utils.PowerShellLanguageId);
const deprecatedSetting = 'codeFormatting.whitespaceAroundPipe'
if (configuration.has(deprecatedSetting) && !configuration.has('codeFormatting.addWhitespaceAroundPipe')) {
const newSetting = 'codeFormatting.addWhitespaceAroundPipe'
const configurationTargetOfNewSetting = await Settings.getEffectiveConfigurationTarget(newSetting);
if (configuration.has(deprecatedSetting) && configurationTargetOfNewSetting === null) {
const configurationTarget = await Settings.getEffectiveConfigurationTarget(deprecatedSetting);
const value = configuration.get(deprecatedSetting, configurationTarget)
await Settings.change('codeFormatting.addWhitespaceAroundPipe', value, configurationTarget);
await Settings.change(newSetting, value, configurationTarget);
}
}

Expand Down

0 comments on commit 252a2c5

Please sign in to comment.