Skip to content

Commit 2d7dd59

Browse files
committed
Make setting defaults consistent and remove bundledModulesPath setting
This wasn't a "setting" anyway because it wasn't settable.
1 parent 91bf1ab commit 2d7dd59

File tree

3 files changed

+15
-24
lines changed

3 files changed

+15
-24
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,6 @@
584584
},
585585
"powershell.powerShellExePath": {
586586
"type": "string",
587-
"default": "",
588587
"scope": "machine",
589588
"description": "REMOVED: Please use the \"powershell.powerShellAdditionalExePaths\" setting instead.",
590589
"deprecationMessage": "Please use the \"powershell.powerShellAdditionalExePaths\" setting instead."
@@ -811,6 +810,7 @@
811810
},
812811
"powershell.integratedConsole.forceClearScrollbackBuffer": {
813812
"type": "boolean",
813+
"default": false,
814814
"description": "Use the vscode API to clear the terminal since that's the only reliable way to clear the scrollback buffer. Turn this on if you're used to 'Clear-Host' clearing scroll history as well as clear-terminal-via-lsp."
815815
},
816816
"powershell.integratedConsole.suppressStartupBanner": {
@@ -825,6 +825,7 @@
825825
},
826826
"powershell.developer.bundledModulesPath": {
827827
"type": "string",
828+
"default": "../../PowerShellEditorServices/module",
828829
"description": "Specifies an alternate path to the folder containing modules that are bundled with the PowerShell extension (i.e. PowerShell Editor Services, PSScriptAnalyzer, Plaster)"
829830
},
830831
"powershell.developer.editorServicesLogLevel": {

src/session.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -525,13 +525,14 @@ export class SessionManager implements Middleware {
525525
}
526526

527527
private async getBundledModulesPath(): Promise<string> {
528-
let bundledModulesPath = path.resolve(__dirname, this.sessionSettings.bundledModulesPath);
528+
// Because the extension is always at `<root>/out/main.js`
529+
let bundledModulesPath = path.resolve(__dirname, "../modules");
529530

530531
if (this.extensionContext.extensionMode === vscode.ExtensionMode.Development) {
531532
const devBundledModulesPath = path.resolve(__dirname, this.sessionSettings.developer.bundledModulesPath);
532533

533534
// Make sure the module's bin path exists
534-
if (await utils.checkIfDirectoryExists(path.join(devBundledModulesPath, "PowerShellEditorServices/bin"))) {
535+
if (await utils.checkIfDirectoryExists(devBundledModulesPath)) {
535536
bundledModulesPath = devBundledModulesPath;
536537
} else {
537538
void this.logger.writeAndShowWarning(

src/settings.ts

+10-21
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ export interface ISettings {
8282
// This setting is no longer used but is here to assist in cleaning up the users settings.
8383
powerShellExePath: string | undefined;
8484
promptToUpdatePowerShell: boolean;
85-
bundledModulesPath: string;
8685
startAsLoginShell: IStartAsLoginShellSettings;
8786
startAutomatically: boolean;
8887
enableProfileLoading: boolean;
@@ -117,10 +116,12 @@ export interface IIntegratedConsoleSettings {
117116
}
118117

119118
export interface ISideBarSettings {
119+
// TODO: add CommandExplorerExcludeFilter
120120
CommandExplorerVisibility: boolean;
121121
}
122122

123123
export interface IPesterSettings {
124+
// TODO: add codeLens property
124125
useLegacyCodeLens: boolean;
125126
outputVerbosity: string;
126127
debugOutputVerbosity: string;
@@ -161,7 +162,7 @@ export function load(): ISettings {
161162

162163
const defaultCodeFoldingSettings: ICodeFoldingSettings = {
163164
enable: true,
164-
showLastLine: false,
165+
showLastLine: true,
165166
};
166167

167168
const defaultCodeFormattingSettings: ICodeFormattingSettings = {
@@ -215,7 +216,10 @@ export function load(): ISettings {
215216
debugOutputVerbosity: "Diagnostic",
216217
};
217218

218-
// TODO: I believe all the defaults can be removed, as the `package.json` should supply them (and be the source of truth).
219+
// TODO: I believe all the defaults can be removed, as the `package.json`
220+
// should supply them (and be the source of truth). However, this proves
221+
// fairly messy to do as it requires casting the configuration to unknown
222+
// and then to `ISettings`. It could work but will take more testing.
219223
return {
220224
startAutomatically:
221225
configuration.get<boolean>("startAutomatically", true),
@@ -227,18 +231,16 @@ export function load(): ISettings {
227231
configuration.get<string>("powerShellExePath"),
228232
promptToUpdatePowerShell:
229233
configuration.get<boolean>("promptToUpdatePowerShell", true),
230-
bundledModulesPath:
231-
"../modules", // Because the extension is always at `<root>/out/main.js`
232234
enableProfileLoading:
233-
configuration.get<boolean>("enableProfileLoading", false),
235+
configuration.get<boolean>("enableProfileLoading", true),
234236
helpCompletion:
235237
configuration.get<string>("helpCompletion", CommentType.BlockComment),
236238
scriptAnalysis:
237239
configuration.get<IScriptAnalysisSettings>("scriptAnalysis", defaultScriptAnalysisSettings),
238240
debugging:
239241
configuration.get<IDebuggingSettings>("debugging", defaultDebuggingSettings),
240242
developer:
241-
getWorkspaceSettingsWithDefaults<IDeveloperSettings>(configuration, "developer", defaultDeveloperSettings),
243+
configuration.get<IDeveloperSettings>("developer", defaultDeveloperSettings),
242244
codeFolding:
243245
configuration.get<ICodeFoldingSettings>("codeFolding", defaultCodeFoldingSettings),
244246
codeFormatting:
@@ -264,7 +266,7 @@ export function load(): ISettings {
264266
enableReferencesCodeLens:
265267
configuration.get<boolean>("enableReferencesCodeLens", true),
266268
analyzeOpenDocumentsOnly:
267-
configuration.get<boolean>("analyzeOpenDocumentsOnly", true),
269+
configuration.get<boolean>("analyzeOpenDocumentsOnly", false),
268270
};
269271
}
270272

@@ -303,19 +305,6 @@ export async function change(
303305
}
304306
}
305307

306-
function getWorkspaceSettingsWithDefaults<TSettings>(
307-
workspaceConfiguration: vscode.WorkspaceConfiguration,
308-
settingName: string,
309-
defaultSettings: TSettings): TSettings {
310-
311-
const importedSettings: TSettings = workspaceConfiguration.get<TSettings>(settingName, defaultSettings);
312-
313-
for (const setting in importedSettings) {
314-
defaultSettings[setting] = importedSettings[setting];
315-
}
316-
return defaultSettings;
317-
}
318-
319308
// We don't want to query the user more than once, so this is idempotent.
320309
let hasPrompted = false;
321310

0 commit comments

Comments
 (0)