-
Notifications
You must be signed in to change notification settings - Fork 514
🔧🚗 Migrate setting value of codeFormatting.whitespaceAroundPipe (if present) to new setting codeFormatting.addWhitespaceAroundPipe automatically. #2689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4e6e6b9
09dd00c
0ab07f9
c69d197
10185d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,8 @@ export class SessionManager implements Middleware { | |
|
||
this.promptPowerShellExeSettingsCleanup(); | ||
|
||
this.migrateWhitespaceAroundPipeSetting(); | ||
|
||
try { | ||
let powerShellExeDetails; | ||
if (this.sessionSettings.powerShellDefaultVersion) { | ||
|
@@ -320,6 +322,18 @@ export class SessionManager implements Middleware { | |
return resolvedCodeLens; | ||
} | ||
|
||
// During preview, populate a new setting value but not remove the old value. | ||
// TODO: When the next stable extension releases, then the old value can be safely removed. Tracked in this issue: https://github.com/PowerShell/vscode-powershell/issues/2693 | ||
private async migrateWhitespaceAroundPipeSetting() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you wanna make this more of a utility function that takes in the old an new setting? That'll be handy in the future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather defer it to when it is needed as it might be a YAGNI. |
||
const configuration = vscode.workspace.getConfiguration(utils.PowerShellLanguageId); | ||
const deprecatedSetting = 'codeFormatting.whitespaceAroundPipe' | ||
if (configuration.has(deprecatedSetting) && !configuration.has('codeFormatting.addWhitespaceAroundPipe')) { | ||
const configurationTarget = await Settings.getEffectiveConfigurationTarget(deprecatedSetting); | ||
const value = configuration.get(deprecatedSetting, configurationTarget) | ||
await Settings.change('codeFormatting.addWhitespaceAroundPipe', value, configurationTarget); | ||
} | ||
} | ||
|
||
private async promptPowerShellExeSettingsCleanup() { | ||
if (this.sessionSettings.powerShellExePath) { | ||
let warningMessage = "The 'powerShell.powerShellExePath' setting is no longer used. "; | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -245,12 +245,32 @@ export function load(): ISettings { | |||||
}; | ||||||
} | ||||||
|
||||||
export async function change(settingName: string, newValue: any, global: boolean = false): Promise<void> { | ||||||
const configuration: vscode.WorkspaceConfiguration = | ||||||
vscode.workspace.getConfiguration( | ||||||
utils.PowerShellLanguageId); | ||||||
// Get the ConfigurationTarget (read: scope) of where the *effective* setting value comes from | ||||||
export async function getEffectiveConfigurationTarget(settingName: string): Promise<vscode.ConfigurationTarget> { | ||||||
const configuration = vscode.workspace.getConfiguration(utils.PowerShellLanguageId); | ||||||
|
||||||
const detail = configuration.inspect(settingName); | ||||||
let configurationTarget = null; | ||||||
if (typeof detail.workspaceFolderValue !== "undefined") { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be this?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I read the link. I think that advice is fine. |
||||||
configurationTarget = vscode.ConfigurationTarget.WorkspaceFolder; | ||||||
} | ||||||
else if (typeof detail.workspaceValue !== "undefined") { | ||||||
configurationTarget = vscode.ConfigurationTarget.Workspace; | ||||||
} | ||||||
else if (typeof detail.globalValue !== "undefined") { | ||||||
configurationTarget = vscode.ConfigurationTarget.Global; | ||||||
} | ||||||
return configurationTarget; | ||||||
} | ||||||
|
||||||
export async function change( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function is functionally still the same , only the |
||||||
settingName: string, | ||||||
newValue: any, | ||||||
configurationTarget?: vscode.ConfigurationTarget | boolean): Promise<void> { | ||||||
|
||||||
const configuration = vscode.workspace.getConfiguration(utils.PowerShellLanguageId); | ||||||
|
||||||
await configuration.update(settingName, newValue, global); | ||||||
await configuration.update(settingName, newValue, configurationTarget); | ||||||
} | ||||||
|
||||||
function getWorkspaceSettingsWithDefaults<TSettings>( | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may want to do this for the next stable release as well since a lot of customers only use stable.
After the next stable version, we can remove the old setting.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's exactly what I try to say: add new setting during preview but leave old setting still there (people who switch between preview/stable or use settings synchronization). Just before the next stable or in the last preview, I'd modify to to additionally remove the old setting. Is that clearer? But it sounds like we are both on the same page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think so. Can you capture this in an issue so we don't forget?
I'd even suggest adding a TODO with the issue number... That way if we all disappear, someone could pickup where we left off
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened issue #2693 and will add a comment