Skip to content

Commit 43b6502

Browse files
Nikola HristovNikola Hristov
authored andcommitted
1 parent d575c2c commit 43b6502

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+485
-0
lines changed

Source/extension/common/application/commands/reportIssueCommand.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ export async function openReportIssue(): Promise<void> {
4040
const virtualEnvKind = interpreter?.environment?.type || "Unknown";
4141

4242
const pythonVersion = getRawVersion(interpreter?.version);
43+
4344
await executeCommand("workbench.action.openIssueReporter", {
4445
extensionId: "ms-python.debugpy",
4546
issueBody: template,
4647
data: userTemplate
4748
.replace("{0}", pythonVersion)
4849
.replace("{1}", virtualEnvKind),
4950
});
51+
5052
sendTelemetryEvent(EventName.USE_REPORT_ISSUE_COMMAND, undefined, {});
5153
}

Source/extension/common/application/debugSessionTelemetry.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ function isResponse(a: any): a is DebugProtocol.Response {
2626
}
2727
class TelemetryTracker implements DebugAdapterTracker {
2828
private timer = new StopWatch();
29+
2930
private readonly trigger: TriggerType = "launch";
31+
3032
private readonly console: ConsoleType | undefined;
3133

3234
constructor(session: DebugSession) {
@@ -35,6 +37,7 @@ class TelemetryTracker implements DebugAdapterTracker {
3537
const debugConfiguration = session.configuration as Partial<
3638
LaunchRequestArguments & AttachRequestArguments
3739
>;
40+
3841
this.console = debugConfiguration.console;
3942
}
4043

@@ -66,11 +69,13 @@ class TelemetryTracker implements DebugAdapterTracker {
6669
if (eventName === EventName.DEBUG_SESSION_START) {
6770
this.timer.reset();
6871
}
72+
6973
const telemetryProps = {
7074
trigger: this.trigger,
7175
console: this.console,
7276
...properties,
7377
};
78+
7479
sendTelemetryEvent(
7580
eventName as keyof IEventNamePropertyMapping,
7681
this.timer.elapsedTime,

Source/extension/common/multiStepInput.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,36 +58,57 @@ export type QuickInputButtonSetup = {
5858
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5959
export interface IQuickPickParameters<T extends QuickPickItem, E = any> {
6060
title?: string;
61+
6162
step?: number;
63+
6264
totalSteps?: number;
65+
6366
canGoBack?: boolean;
67+
6468
items: T[];
69+
6570
activeItem?: T | ((quickPick: QuickPick<T>) => Promise<T>);
71+
6672
placeholder: string | undefined;
73+
6774
customButtonSetups?: QuickInputButtonSetup[];
75+
6876
matchOnDescription?: boolean;
77+
6978
matchOnDetail?: boolean;
79+
7080
keepScrollPosition?: boolean;
81+
7182
acceptFilterBoxTextAsSelection?: boolean;
7283
/**
7384
* A method called only after quickpick has been created and all handlers are registered.
7485
*/
7586
initialize?: (quickPick: QuickPick<T>) => void;
87+
7688
onChangeItem?: {
7789
callback: (event: E, quickPick: QuickPick<T>) => void;
90+
7891
event: Event<E>;
7992
};
93+
8094
onDidTriggerItemButton?: (e: QuickPickItemButtonEvent<T>) => void;
8195
}
8296

8397
interface InputBoxParameters {
8498
title: string;
99+
85100
password?: boolean;
101+
86102
step?: number;
103+
87104
totalSteps?: number;
105+
88106
value: string;
107+
89108
prompt: string;
109+
90110
buttons?: QuickInputButton[];
111+
91112
validate(value: string): Promise<string | undefined>;
92113
}
93114

@@ -102,6 +123,7 @@ type MultiStepInputInputBoxResponseType<P> =
102123

103124
export interface IMultiStepInput<S> {
104125
run(start: InputStep<S>, state: S): Promise<void>;
126+
105127
showQuickPick<T extends QuickPickItem, P extends IQuickPickParameters<T>>({
106128
title,
107129
step,
@@ -111,6 +133,7 @@ export interface IMultiStepInput<S> {
111133
placeholder,
112134
customButtonSetups,
113135
}: P): Promise<MultiStepInputQuickPickResponseType<T, P>>;
136+
114137
showInputBox<P extends InputBoxParameters>({
115138
title,
116139
step,
@@ -155,24 +178,35 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
155178
const disposables: Disposable[] = [];
156179

157180
const input = window.createQuickPick<T>();
181+
158182
input.title = title;
183+
159184
input.step = step;
185+
160186
input.totalSteps = totalSteps;
187+
161188
input.placeholder = placeholder;
189+
162190
input.ignoreFocusOut = true;
191+
163192
input.items = items;
193+
164194
input.matchOnDescription = matchOnDescription || false;
195+
165196
input.matchOnDetail = matchOnDetail || false;
197+
166198
input.buttons = this.steps.length > 1 ? [QuickInputButtons.Back] : [];
167199

168200
if (customButtonSetups) {
169201
for (const customButtonSetup of customButtonSetups) {
170202
input.buttons = [...input.buttons, customButtonSetup.button];
171203
}
172204
}
205+
173206
if (this.current) {
174207
this.current.dispose();
175208
}
209+
176210
this.current = input;
177211

178212
if (onChangeItem) {
@@ -184,6 +218,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
184218
if (initialize) {
185219
initialize(input);
186220
}
221+
187222
if (activeItem) {
188223
if (typeof activeItem === "function") {
189224
activeItem(input).then((item) => {
@@ -195,6 +230,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
195230
} else {
196231
input.activeItems = [];
197232
}
233+
198234
this.current.show();
199235
// Keep scroll position is only meant to keep scroll position when updating items,
200236
// so do it after initialization. This ensures quickpick starts with the active
@@ -207,8 +243,10 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
207243
input.onDidTriggerButton(async (item) => {
208244
if (item === QuickInputButtons.Back) {
209245
deferred.reject(InputFlowAction.back);
246+
210247
input.hide();
211248
}
249+
212250
if (customButtonSetups) {
213251
for (const customButtonSetup of customButtonSetups) {
214252
if (
@@ -280,13 +318,21 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
280318
return await new Promise<MultiStepInputInputBoxResponseType<P>>(
281319
(resolve, reject) => {
282320
const input = window.createInputBox();
321+
283322
input.title = title;
323+
284324
input.step = step;
325+
285326
input.totalSteps = totalSteps;
327+
286328
input.password = !!password;
329+
287330
input.value = value || "";
331+
288332
input.prompt = prompt;
333+
289334
input.ignoreFocusOut = true;
335+
290336
input.buttons = [
291337
...(this.steps.length > 1
292338
? [QuickInputButtons.Back]
@@ -295,6 +341,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
295341
];
296342

297343
let validating = validate("");
344+
298345
disposables.push(
299346
input.onDidTriggerButton((item) => {
300347
if (item === QuickInputButtons.Back) {
@@ -306,17 +353,22 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
306353
}),
307354
input.onDidAccept(async () => {
308355
const inputValue = input.value;
356+
309357
input.enabled = false;
358+
310359
input.busy = true;
311360

312361
if (!(await validate(inputValue))) {
313362
resolve(inputValue);
314363
}
364+
315365
input.enabled = true;
366+
316367
input.busy = false;
317368
}),
318369
input.onDidChangeValue(async (text) => {
319370
const current = validate(text);
371+
320372
validating = current;
321373

322374
const validationMessage = await current;
@@ -333,7 +385,9 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
333385
if (this.current) {
334386
this.current.dispose();
335387
}
388+
336389
this.current = input;
390+
337391
this.current.show();
338392
},
339393
);
@@ -350,13 +404,16 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
350404

351405
if (this.current) {
352406
this.current.enabled = false;
407+
353408
this.current.busy = true;
354409
}
410+
355411
try {
356412
step = await step(this, state);
357413
} catch (err) {
358414
if (err === InputFlowAction.back) {
359415
this.steps.pop();
416+
360417
step = this.steps.pop();
361418

362419
if (step === undefined) {
@@ -371,6 +428,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
371428
}
372429
}
373430
}
431+
374432
if (this.current) {
375433
this.current.dispose();
376434
}

Source/extension/common/persistentState.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class PersistentState<T> implements IPersistentState<T> {
5656
} else {
5757
await this.storage.update(this.key, newValue);
5858
}
59+
5960
if (
6061
retryOnce &&
6162
JSON.stringify(this.value) !== JSON.stringify(newValue)
@@ -68,7 +69,9 @@ export class PersistentState<T> implements IPersistentState<T> {
6869
this.key,
6970
" retrying by resetting first",
7071
);
72+
7173
await this.updateValue(undefined as any, false);
74+
7275
await this.updateValue(newValue, false);
7376

7477
if (JSON.stringify(this.value) !== JSON.stringify(newValue)) {
@@ -102,20 +105,26 @@ export class PersistentStateFactory implements IPersistentStateFactory {
102105
untrustedWorkspace: false,
103106
virtualWorkspace: true,
104107
};
108+
105109
private globalState: Memento;
110+
106111
private workspaceState: Memento;
112+
107113
public readonly _globalKeysStorage: PersistentState<KeysStorage[]>;
108114

109115
public readonly _workspaceKeysStorage: PersistentState<KeysStorage[]>;
110116

111117
constructor(globalState: Memento, workspaceState: Memento) {
112118
this.globalState = globalState;
119+
113120
this.workspaceState = workspaceState;
121+
114122
this._globalKeysStorage = new PersistentState<KeysStorage[]>(
115123
this.globalState,
116124
GLOBAL_PERSISTENT_KEYS,
117125
[],
118126
);
127+
119128
this._workspaceKeysStorage = new PersistentState<KeysStorage[]>(
120129
this.workspaceState,
121130
WORKSPACE_PERSISTENT_KEYS,
@@ -144,6 +153,7 @@ export class PersistentStateFactory implements IPersistentStateFactory {
144153
if (globalKeysStorageDeprecated.value.length > 0) {
145154
ignoreErrors(globalKeysStorageDeprecated.updateValue([]));
146155
}
156+
147157
if (workspaceKeysStorageDeprecated.value.length > 0) {
148158
ignoreErrors(workspaceKeysStorageDeprecated.updateValue([]));
149159
}
@@ -210,19 +220,25 @@ export class PersistentStateFactory implements IPersistentStateFactory {
210220
const storage = this.createGlobalPersistentState(
211221
keyContent.key,
212222
);
223+
213224
await storage.updateValue(keyContent.defaultValue);
214225
}),
215226
);
227+
216228
await Promise.all(
217229
this._workspaceKeysStorage.value.map(async (keyContent) => {
218230
const storage = this.createWorkspacePersistentState(
219231
keyContent.key,
220232
);
233+
221234
await storage.updateValue(keyContent.defaultValue);
222235
}),
223236
);
237+
224238
await this._globalKeysStorage.updateValue([]);
239+
225240
await this._workspaceKeysStorage.updateValue([]);
241+
226242
executeCommand("workbench.action.reloadWindow").then(noop);
227243
}
228244
}
@@ -257,8 +273,10 @@ export function getGlobalStorage<T>(
257273

258274
if (!found) {
259275
const newValue = [{ key, defaultValue }, ...globalKeysStorage.value];
276+
260277
ignoreErrors(globalKeysStorage.updateValue(newValue));
261278
}
279+
262280
const raw = new PersistentState<T>(context.globalState, key, defaultValue);
263281

264282
return {

Source/extension/common/platform.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ export function getUserHomeDir(): string | undefined {
4848
if (getOSType() === OSType.Windows) {
4949
return getEnvironmentVariable("USERPROFILE");
5050
}
51+
5152
return getEnvironmentVariable("HOME") || getEnvironmentVariable("HOMEPATH");
5253
}

0 commit comments

Comments
 (0)