Skip to content

Commit 237fb52

Browse files
committed
Fix up ISettings
* Stop exporting things unused elsewhere * Remove unnecessary getWorkspaceSettingsWithDefaults * Make `settings.ts` and `package.json` defaults consistent
1 parent 3e12445 commit 237fb52

File tree

3 files changed

+64
-60
lines changed

3 files changed

+64
-60
lines changed

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -573,18 +573,20 @@
573573
},
574574
"powershell.powerShellAdditionalExePaths": {
575575
"type": "object",
576+
"default": null,
576577
"description": "Specifies a list of versionName / exePath pairs where exePath points to a non-standard install location for PowerShell and versionName can be used to reference this path with the powershell.powerShellDefaultVersion setting.",
577578
"additionalProperties": {
578579
"type": "string"
579580
}
580581
},
581582
"powershell.powerShellDefaultVersion": {
582583
"type": "string",
584+
"default": null,
583585
"description": "Specifies the PowerShell version name, as displayed by the 'PowerShell: Show Session Menu' command, used when the extension loads e.g \"Windows PowerShell (x86)\" or \"PowerShell Core 7 (x64)\". You can specify additional PowerShell executables by using the \"powershell.powerShellAdditionalExePaths\" setting."
584586
},
585587
"powershell.powerShellExePath": {
586588
"type": "string",
587-
"default": "",
589+
"default": null,
588590
"scope": "machine",
589591
"description": "REMOVED: Please use the \"powershell.powerShellAdditionalExePaths\" setting instead.",
590592
"deprecationMessage": "Please use the \"powershell.powerShellAdditionalExePaths\" setting instead."
@@ -811,6 +813,7 @@
811813
},
812814
"powershell.integratedConsole.forceClearScrollbackBuffer": {
813815
"type": "boolean",
816+
"default": false,
814817
"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."
815818
},
816819
"powershell.integratedConsole.suppressStartupBanner": {
@@ -825,6 +828,7 @@
825828
},
826829
"powershell.developer.bundledModulesPath": {
827830
"type": "string",
831+
"default": "../../PowerShellEditorServices/module",
828832
"description": "Specifies an alternate path to the folder containing modules that are bundled with the PowerShell extension (i.e. PowerShell Editor Services, PSScriptAnalyzer, Plaster)"
829833
},
830834
"powershell.developer.editorServicesLogLevel": {

src/session.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -575,9 +575,7 @@ Type 'help' to get help.
575575
editorServicesArgs += "-WaitForDebugger ";
576576
}
577577

578-
if (this.sessionSettings.developer.editorServicesLogLevel) {
579-
editorServicesArgs += `-LogLevel '${this.sessionSettings.developer.editorServicesLogLevel}' `;
580-
}
578+
editorServicesArgs += `-LogLevel '${this.sessionSettings.developer.editorServicesLogLevel}' `;
581579

582580
return editorServicesArgs;
583581
}

src/settings.ts

+58-56
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,54 @@ import utils = require("./utils");
66
import os = require("os");
77
import { Logger } from "./logging";
88

9-
enum CodeFormattingPreset {
10-
Custom,
11-
Allman,
12-
OTBS,
13-
Stroustrup,
9+
export interface ISettings {
10+
powerShellAdditionalExePaths: IPowerShellAdditionalExePathSettings | undefined;
11+
powerShellDefaultVersion: string | undefined;
12+
// This setting is no longer used but is here to assist in cleaning up the users settings.
13+
powerShellExePath: string | undefined;
14+
promptToUpdatePowerShell: boolean;
15+
bundledModulesPath: string;
16+
startAsLoginShell: IStartAsLoginShellSettings;
17+
startAutomatically: boolean;
18+
enableProfileLoading: boolean;
19+
helpCompletion: string;
20+
scriptAnalysis: IScriptAnalysisSettings;
21+
debugging: IDebuggingSettings;
22+
developer: IDeveloperSettings;
23+
codeFolding: ICodeFoldingSettings;
24+
codeFormatting: ICodeFormattingSettings;
25+
integratedConsole: IIntegratedConsoleSettings;
26+
bugReporting: IBugReportingSettings;
27+
sideBar: ISideBarSettings;
28+
pester: IPesterSettings;
29+
buttons: IButtonSettings;
30+
cwd: string | undefined;
31+
enableReferencesCodeLens: boolean;
32+
analyzeOpenDocumentsOnly: boolean;
33+
// TODO: Add (deprecated) useX86Host (for testing)
34+
}
35+
36+
export enum CodeFormattingPreset {
37+
Custom = "Custom",
38+
Allman = "Allman",
39+
OTBS = "OTBS",
40+
Stroustrup = "Stroustrup",
1441
}
1542

16-
enum PipelineIndentationStyle {
17-
IncreaseIndentationForFirstPipeline,
18-
IncreaseIndentationAfterEveryPipeline,
19-
NoIndentation,
20-
None,
43+
export enum PipelineIndentationStyle {
44+
IncreaseIndentationForFirstPipeline = "IncreaseIndentationForFirstPipeline",
45+
IncreaseIndentationAfterEveryPipeline = "IncreaseIndentationAfterEveryPipeline",
46+
NoIndentation = "NoIndentation",
47+
None = "None",
48+
}
49+
50+
export enum LogLevel {
51+
Diagnostic = "Diagnostic",
52+
Verbose = "Verbose",
53+
Normal = "Normal",
54+
Warning = "Warning",
55+
Error = "Error",
56+
None = "None",
2157
}
2258

2359
export enum CommentType {
@@ -71,37 +107,11 @@ export interface IDebuggingSettings {
71107
export interface IDeveloperSettings {
72108
featureFlags: string[];
73109
bundledModulesPath: string;
74-
editorServicesLogLevel: string;
110+
editorServicesLogLevel: LogLevel;
75111
editorServicesWaitForDebugger: boolean;
76112
waitForSessionFileTimeoutSeconds: number;
77113
}
78114

79-
export interface ISettings {
80-
powerShellAdditionalExePaths: IPowerShellAdditionalExePathSettings | undefined;
81-
powerShellDefaultVersion: string | undefined;
82-
// This setting is no longer used but is here to assist in cleaning up the users settings.
83-
powerShellExePath: string | undefined;
84-
promptToUpdatePowerShell: boolean;
85-
bundledModulesPath: string;
86-
startAsLoginShell: IStartAsLoginShellSettings;
87-
startAutomatically: boolean;
88-
enableProfileLoading: boolean;
89-
helpCompletion: string;
90-
scriptAnalysis: IScriptAnalysisSettings;
91-
debugging: IDebuggingSettings;
92-
developer: IDeveloperSettings;
93-
codeFolding: ICodeFoldingSettings;
94-
codeFormatting: ICodeFormattingSettings;
95-
integratedConsole: IIntegratedConsoleSettings;
96-
bugReporting: IBugReportingSettings;
97-
sideBar: ISideBarSettings;
98-
pester: IPesterSettings;
99-
buttons: IButtonSettings;
100-
cwd: string | undefined;
101-
enableReferencesCodeLens: boolean;
102-
analyzeOpenDocumentsOnly: boolean;
103-
}
104-
105115
export interface IStartAsLoginShellSettings {
106116
osx: boolean;
107117
linux: boolean;
@@ -117,10 +127,12 @@ export interface IIntegratedConsoleSettings {
117127
}
118128

119129
export interface ISideBarSettings {
130+
// TODO: add CommandExplorerExcludeFilter
120131
CommandExplorerVisibility: boolean;
121132
}
122133

123134
export interface IPesterSettings {
135+
// TODO: add codeLens property
124136
useLegacyCodeLens: boolean;
125137
outputVerbosity: string;
126138
debugOutputVerbosity: string;
@@ -154,14 +166,14 @@ export function load(): ISettings {
154166
// From `<root>/out/main.js` we go to the directory before <root> and
155167
// then into the other repo.
156168
bundledModulesPath: "../../PowerShellEditorServices/module",
157-
editorServicesLogLevel: "Normal",
169+
editorServicesLogLevel: LogLevel.Normal,
158170
editorServicesWaitForDebugger: false,
159171
waitForSessionFileTimeoutSeconds: 240,
160172
};
161173

162174
const defaultCodeFoldingSettings: ICodeFoldingSettings = {
163175
enable: true,
164-
showLastLine: false,
176+
showLastLine: true,
165177
};
166178

167179
const defaultCodeFormattingSettings: ICodeFormattingSettings = {
@@ -215,7 +227,10 @@ export function load(): ISettings {
215227
debugOutputVerbosity: "Diagnostic",
216228
};
217229

218-
// TODO: I believe all the defaults can be removed, as the `package.json` should supply them (and be the source of truth).
230+
// TODO: I believe all the defaults can be removed, as the `package.json`
231+
// should supply them (and be the source of truth). However, this proves
232+
// fairly messy to do as it requires casting the configuration to unknown
233+
// and then to `ISettings`. It could work but will take more testing.
219234
return {
220235
startAutomatically:
221236
configuration.get<boolean>("startAutomatically", true),
@@ -230,15 +245,15 @@ export function load(): ISettings {
230245
bundledModulesPath:
231246
"../modules", // Because the extension is always at `<root>/out/main.js`
232247
enableProfileLoading:
233-
configuration.get<boolean>("enableProfileLoading", false),
248+
configuration.get<boolean>("enableProfileLoading", true),
234249
helpCompletion:
235250
configuration.get<string>("helpCompletion", CommentType.BlockComment),
236251
scriptAnalysis:
237252
configuration.get<IScriptAnalysisSettings>("scriptAnalysis", defaultScriptAnalysisSettings),
238253
debugging:
239254
configuration.get<IDebuggingSettings>("debugging", defaultDebuggingSettings),
240255
developer:
241-
getWorkspaceSettingsWithDefaults<IDeveloperSettings>(configuration, "developer", defaultDeveloperSettings),
256+
configuration.get<IDeveloperSettings>("developer", defaultDeveloperSettings),
242257
codeFolding:
243258
configuration.get<ICodeFoldingSettings>("codeFolding", defaultCodeFoldingSettings),
244259
codeFormatting:
@@ -264,7 +279,7 @@ export function load(): ISettings {
264279
enableReferencesCodeLens:
265280
configuration.get<boolean>("enableReferencesCodeLens", true),
266281
analyzeOpenDocumentsOnly:
267-
configuration.get<boolean>("analyzeOpenDocumentsOnly", true),
282+
configuration.get<boolean>("analyzeOpenDocumentsOnly", false),
268283
};
269284
}
270285

@@ -303,19 +318,6 @@ export async function change(
303318
}
304319
}
305320

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-
319321
// We don't want to query the user more than once, so this is idempotent.
320322
let hasPrompted = false;
321323

0 commit comments

Comments
 (0)