@@ -6,18 +6,53 @@ import utils = require("./utils");
6
6
import os = require( "os" ) ;
7
7
import { Logger } from "./logging" ;
8
8
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
+ }
34
+
9
35
enum CodeFormattingPreset {
10
- Custom ,
11
- Allman ,
12
- OTBS ,
13
- Stroustrup ,
36
+ Custom = "Custom" ,
37
+ Allman = "Allman" ,
38
+ OTBS = "OTBS" ,
39
+ Stroustrup = "Stroustrup" ,
14
40
}
15
41
16
42
enum PipelineIndentationStyle {
17
- IncreaseIndentationForFirstPipeline ,
18
- IncreaseIndentationAfterEveryPipeline ,
19
- NoIndentation ,
20
- None ,
43
+ IncreaseIndentationForFirstPipeline = "IncreaseIndentationForFirstPipeline" ,
44
+ IncreaseIndentationAfterEveryPipeline = "IncreaseIndentationAfterEveryPipeline" ,
45
+ NoIndentation = "NoIndentation" ,
46
+ None = "None" ,
47
+ }
48
+
49
+ enum LogLevel {
50
+ Diagnostic = "Diagnostic" ,
51
+ Verbose = "Verbose" ,
52
+ Normal = "Normal" ,
53
+ Warning = "Warning" ,
54
+ Error = "Error" ,
55
+ None = "None" ,
21
56
}
22
57
23
58
export enum CommentType {
@@ -28,16 +63,16 @@ export enum CommentType {
28
63
29
64
export type IPowerShellAdditionalExePathSettings = Record < string , string > ;
30
65
31
- export interface IBugReportingSettings {
66
+ interface IBugReportingSettings {
32
67
project : string ;
33
68
}
34
69
35
- export interface ICodeFoldingSettings {
70
+ interface ICodeFoldingSettings {
36
71
enable : boolean ;
37
72
showLastLine : boolean ;
38
73
}
39
74
40
- export interface ICodeFormattingSettings {
75
+ interface ICodeFormattingSettings {
41
76
autoCorrectAliases : boolean ;
42
77
avoidSemicolonsAsLineTerminators : boolean ;
43
78
preset : CodeFormattingPreset ;
@@ -59,55 +94,29 @@ export interface ICodeFormattingSettings {
59
94
useCorrectCasing : boolean ;
60
95
}
61
96
62
- export interface IScriptAnalysisSettings {
97
+ interface IScriptAnalysisSettings {
63
98
enable : boolean ;
64
99
settingsPath : string ;
65
100
}
66
101
67
- export interface IDebuggingSettings {
102
+ interface IDebuggingSettings {
68
103
createTemporaryIntegratedConsole : boolean ;
69
104
}
70
105
71
- export interface IDeveloperSettings {
106
+ interface IDeveloperSettings {
72
107
featureFlags : string [ ] ;
73
108
bundledModulesPath : string ;
74
- editorServicesLogLevel : string ;
109
+ editorServicesLogLevel : LogLevel ;
75
110
editorServicesWaitForDebugger : boolean ;
76
111
waitForSessionFileTimeoutSeconds : number ;
77
112
}
78
113
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
-
105
- export interface IStartAsLoginShellSettings {
114
+ interface IStartAsLoginShellSettings {
106
115
osx : boolean ;
107
116
linux : boolean ;
108
117
}
109
118
110
- export interface IIntegratedConsoleSettings {
119
+ interface IIntegratedConsoleSettings {
111
120
showOnStartup : boolean ;
112
121
startInBackground : boolean ;
113
122
focusConsoleOnExecute : boolean ;
@@ -116,17 +125,17 @@ export interface IIntegratedConsoleSettings {
116
125
suppressStartupBanner : boolean ;
117
126
}
118
127
119
- export interface ISideBarSettings {
128
+ interface ISideBarSettings {
120
129
CommandExplorerVisibility : boolean ;
121
130
}
122
131
123
- export interface IPesterSettings {
132
+ interface IPesterSettings {
124
133
useLegacyCodeLens : boolean ;
125
134
outputVerbosity : string ;
126
135
debugOutputVerbosity : string ;
127
136
}
128
137
129
- export interface IButtonSettings {
138
+ interface IButtonSettings {
130
139
showRunButtons : boolean ;
131
140
showPanelMovementButtons : boolean ;
132
141
}
@@ -154,14 +163,14 @@ export function load(): ISettings {
154
163
// From `<root>/out/main.js` we go to the directory before <root> and
155
164
// then into the other repo.
156
165
bundledModulesPath : "../../PowerShellEditorServices/module" ,
157
- editorServicesLogLevel : " Normal" ,
166
+ editorServicesLogLevel : LogLevel . Normal ,
158
167
editorServicesWaitForDebugger : false ,
159
168
waitForSessionFileTimeoutSeconds : 240 ,
160
169
} ;
161
170
162
171
const defaultCodeFoldingSettings : ICodeFoldingSettings = {
163
172
enable : true ,
164
- showLastLine : false ,
173
+ showLastLine : true ,
165
174
} ;
166
175
167
176
const defaultCodeFormattingSettings : ICodeFormattingSettings = {
@@ -215,7 +224,10 @@ export function load(): ISettings {
215
224
debugOutputVerbosity : "Diagnostic" ,
216
225
} ;
217
226
218
- // TODO: I believe all the defaults can be removed, as the `package.json` should supply them (and be the source of truth).
227
+ // TODO: I believe all the defaults can be removed, as the `package.json`
228
+ // should supply them (and be the source of truth). However, this proves
229
+ // fairly messy to do as it requires casting the configuration to unknown
230
+ // and then to `ISettings`. It could work but will take more testing.
219
231
return {
220
232
startAutomatically :
221
233
configuration . get < boolean > ( "startAutomatically" , true ) ,
@@ -230,15 +242,15 @@ export function load(): ISettings {
230
242
bundledModulesPath :
231
243
"../modules" , // Because the extension is always at `<root>/out/main.js`
232
244
enableProfileLoading :
233
- configuration . get < boolean > ( "enableProfileLoading" , false ) ,
245
+ configuration . get < boolean > ( "enableProfileLoading" , true ) ,
234
246
helpCompletion :
235
247
configuration . get < string > ( "helpCompletion" , CommentType . BlockComment ) ,
236
248
scriptAnalysis :
237
249
configuration . get < IScriptAnalysisSettings > ( "scriptAnalysis" , defaultScriptAnalysisSettings ) ,
238
250
debugging :
239
251
configuration . get < IDebuggingSettings > ( "debugging" , defaultDebuggingSettings ) ,
240
252
developer :
241
- getWorkspaceSettingsWithDefaults < IDeveloperSettings > ( configuration , "developer" , defaultDeveloperSettings ) ,
253
+ configuration . get < IDeveloperSettings > ( "developer" , defaultDeveloperSettings ) ,
242
254
codeFolding :
243
255
configuration . get < ICodeFoldingSettings > ( "codeFolding" , defaultCodeFoldingSettings ) ,
244
256
codeFormatting :
@@ -264,7 +276,7 @@ export function load(): ISettings {
264
276
enableReferencesCodeLens :
265
277
configuration . get < boolean > ( "enableReferencesCodeLens" , true ) ,
266
278
analyzeOpenDocumentsOnly :
267
- configuration . get < boolean > ( "analyzeOpenDocumentsOnly" , true ) ,
279
+ configuration . get < boolean > ( "analyzeOpenDocumentsOnly" , false ) ,
268
280
} ;
269
281
}
270
282
@@ -303,19 +315,6 @@ export async function change(
303
315
}
304
316
}
305
317
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
-
319
318
// We don't want to query the user more than once, so this is idempotent.
320
319
let hasPrompted = false ;
321
320
0 commit comments