Skip to content

Commit 05f66a2

Browse files
Nikola HristovNikola Hristov
authored andcommitted
1 parent e349093 commit 05f66a2

Some content is hidden

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

57 files changed

+376
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,21 @@ export async function openReportIssue(): Promise<void> {
2222
"resources",
2323
"report_issue_template.md",
2424
);
25+
2526
const userDataTemplatePath = path.join(
2627
EXTENSION_ROOT_DIR,
2728
"resources",
2829
"report_issue_user_data_template.md",
2930
);
31+
3032
const template = await fs.readFile(templatePath, "utf8");
33+
3134
const userTemplate = await fs.readFile(userDataTemplatePath, "utf8");
35+
3236
const interpreterPath = await getActiveEnvironmentPath();
37+
3338
const interpreter = await resolveEnvironment(interpreterPath);
39+
3440
const virtualEnvKind = interpreter?.environment?.type || "Unknown";
3541

3642
const pythonVersion = getRawVersion(interpreter?.version);

Source/extension/common/application/debugSessionTelemetry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class TelemetryTracker implements DebugAdapterTracker {
3131

3232
constructor(session: DebugSession) {
3333
this.trigger = session.configuration.request as TriggerType;
34+
3435
const debugConfiguration = session.configuration as Partial<
3536
LaunchRequestArguments & AttachRequestArguments
3637
>;
@@ -83,6 +84,7 @@ export class DebugSessionTelemetry implements DebugAdapterTrackerFactory {
8384
untrustedWorkspace: false,
8485
virtualWorkspace: true,
8586
};
87+
8688
constructor() {}
8789

8890
public createDebugAdapterTracker(

Source/extension/common/constants.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import * as path from "path";
66

77
export const PYTHON_LANGUAGE = "python";
8+
89
const folderName = path.basename(__dirname);
910
export const EXTENSION_ROOT_DIR =
1011
folderName === "common"
@@ -44,16 +45,26 @@ export function isUnitTestExecution(): boolean {
4445

4546
export namespace Commands {
4647
export const Debug_In_Terminal = "debugpy.debugInTerminal";
48+
4749
export const Debug_Using_Launch_Config = "debugpy.debugUsingLaunchConfig";
50+
4851
export const TriggerEnvironmentSelection = "debugpy.triggerEnvSelection";
52+
4953
export const PickLocalProcess = "debugpy.pickLocalProcess";
54+
5055
export const PickArguments = "debugpy.pickArgs";
56+
5157
export const ViewOutput = "debugpy.viewOutput";
58+
5259
export const ClearStorage = "debugpy.clearCacheAndReload";
60+
5361
export const Enable_SourceMap_Support = "debugpy.enableSourceMapSupport";
62+
5463
export const SelectDebugConfig =
5564
"debugpy.SelectAndInsertDebugConfiguration";
65+
5666
export const Set_Interpreter = "python.setInterpreter";
67+
5768
export const ReportIssue = "debugpy.reportIssue";
5869
}
5970

Source/extension/common/log/logging.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class OutputChannelLogger {
3333
let channel: OutputChannelLogger | undefined;
3434
export function registerLogger(logChannel: LogOutputChannel): Disposable {
3535
channel = new OutputChannelLogger(logChannel);
36+
3637
return {
3738
dispose: () => {
3839
channel = undefined;

Source/extension/common/multiStepInput.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
152152
initialize,
153153
}: P): Promise<MultiStepInputQuickPickResponseType<T, P>> {
154154
const disposables: Disposable[] = [];
155+
155156
const input = window.createQuickPick<T>();
156157
input.title = title;
157158
input.step = step;
@@ -162,6 +163,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
162163
input.matchOnDescription = matchOnDescription || false;
163164
input.matchOnDetail = matchOnDetail || false;
164165
input.buttons = this.steps.length > 1 ? [QuickInputButtons.Back] : [];
166+
165167
if (customButtonSetups) {
166168
for (const customButtonSetup of customButtonSetups) {
167169
input.buttons = [...input.buttons, customButtonSetup.button];
@@ -171,6 +173,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
171173
this.current.dispose();
172174
}
173175
this.current = input;
176+
174177
if (onChangeItem) {
175178
disposables.push(
176179
onChangeItem.event((e) => onChangeItem.callback(e, input)),
@@ -230,6 +233,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
230233
}
231234
}),
232235
);
236+
233237
if (acceptFilterBoxTextAsSelection) {
234238
disposables.push(
235239
input.onDidAccept(() => {
@@ -270,6 +274,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
270274
buttons,
271275
}: P): Promise<MultiStepInputInputBoxResponseType<P>> {
272276
const disposables: Disposable[] = [];
277+
273278
try {
274279
return await new Promise<MultiStepInputInputBoxResponseType<P>>(
275280
(resolve, reject) => {
@@ -287,6 +292,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
287292
: []),
288293
...(buttons || []),
289294
];
295+
290296
let validating = validate("");
291297
disposables.push(
292298
input.onDidTriggerButton((item) => {
@@ -301,6 +307,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
301307
const inputValue = input.value;
302308
input.enabled = false;
303309
input.busy = true;
310+
304311
if (!(await validate(inputValue))) {
305312
resolve(inputValue);
306313
}
@@ -310,7 +317,9 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
310317
input.onDidChangeValue(async (text) => {
311318
const current = validate(text);
312319
validating = current;
320+
313321
const validationMessage = await current;
322+
314323
if (current === validating) {
315324
input.validationMessage = validationMessage;
316325
}
@@ -319,6 +328,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
319328
resolve(undefined);
320329
}),
321330
);
331+
322332
if (this.current) {
323333
this.current.dispose();
324334
}
@@ -333,8 +343,10 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
333343

334344
private async stepThrough(start: InputStep<S>, state: S) {
335345
let step: InputStep<S> | void = start;
346+
336347
while (step) {
337348
this.steps.push(step);
349+
338350
if (this.current) {
339351
this.current.enabled = false;
340352
this.current.busy = true;
@@ -345,6 +357,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
345357
if (err === InputFlowAction.back) {
346358
this.steps.pop();
347359
step = this.steps.pop();
360+
348361
if (step === undefined) {
349362
throw err;
350363
}

Source/extension/common/persistentState.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class PersistentState<T> implements IPersistentState<T> {
3131
this.key,
3232
{ data: this.defaultValue! },
3333
);
34+
3435
if (
3536
!cachedData ||
3637
!cachedData.expiry ||
@@ -69,6 +70,7 @@ export class PersistentState<T> implements IPersistentState<T> {
6970
);
7071
await this.updateValue(undefined as any, false);
7172
await this.updateValue(newValue, false);
73+
7274
if (JSON.stringify(this.value) !== JSON.stringify(newValue)) {
7375
traceWarn(
7476
"Retry failed, storage update failed for key",
@@ -88,6 +90,7 @@ export const WORKSPACE_PERSISTENT_KEYS_DEPRECATED =
8890
"PYTHON_EXTENSION_WORKSPACE_STORAGE_KEYS";
8991

9092
const GLOBAL_PERSISTENT_KEYS = "PYTHON_GLOBAL_STORAGE_KEYS";
93+
9194
const WORKSPACE_PERSISTENT_KEYS = "PYTHON_WORKSPACE_STORAGE_KEYS";
9295
type KeysStorageType = "global" | "workspace";
9396
export type KeysStorage = { key: string; defaultValue: unknown };
@@ -123,10 +126,12 @@ export class PersistentStateFactory implements IPersistentStateFactory {
123126
Commands.ClearStorage,
124127
this.cleanAllPersistentStates.bind(this),
125128
);
129+
126130
const globalKeysStorageDeprecated = this.createGlobalPersistentState(
127131
GLOBAL_PERSISTENT_KEYS_DEPRECATED,
128132
[],
129133
);
134+
130135
const workspaceKeysStorageDeprecated =
131136
this.createWorkspacePersistentState(
132137
WORKSPACE_PERSISTENT_KEYS_DEPRECATED,
@@ -148,6 +153,7 @@ export class PersistentStateFactory implements IPersistentStateFactory {
148153
expiryDurationMs?: number,
149154
): IPersistentState<T> {
150155
ignoreErrors(this.addKeyToStorage("global", key, defaultValue));
156+
151157
return new PersistentState<T>(
152158
this.globalState,
153159
key,
@@ -162,6 +168,7 @@ export class PersistentStateFactory implements IPersistentStateFactory {
162168
expiryDurationMs?: number,
163169
): IPersistentState<T> {
164170
ignoreErrors(this.addKeyToStorage("workspace", key, defaultValue));
171+
165172
return new PersistentState<T>(
166173
this.workspaceState,
167174
key,
@@ -184,7 +191,9 @@ export class PersistentStateFactory implements IPersistentStateFactory {
184191
keyStorageType === "global"
185192
? this._globalKeysStorage
186193
: this._workspaceKeysStorage;
194+
187195
const found = storage.value.find((value) => value.key === key);
196+
188197
if (!found) {
189198
await storage.updateValue([
190199
{ key, defaultValue },
@@ -222,6 +231,7 @@ export class PersistentStateFactory implements IPersistentStateFactory {
222231

223232
export interface IPersistentStorage<T> {
224233
get(): T;
234+
225235
set(value: T): Promise<void>;
226236
}
227237

@@ -238,14 +248,17 @@ export function getGlobalStorage<T>(
238248
GLOBAL_PERSISTENT_KEYS,
239249
[],
240250
);
251+
241252
const found = globalKeysStorage.value.find(
242253
(value) => value.key === key && value.defaultValue === defaultValue,
243254
);
255+
244256
if (!found) {
245257
const newValue = [{ key, defaultValue }, ...globalKeysStorage.value];
246258
ignoreErrors(globalKeysStorage.updateValue(newValue));
247259
}
248260
const raw = new PersistentState<T>(context.globalState, key, defaultValue);
261+
249262
return {
250263
// We adapt between PersistentState and IPersistentStorage.
251264
get() {

Source/extension/common/process/decoder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ export function decodeBuffer(
1010
encoding: string = DEFAULT_ENCODING,
1111
): string {
1212
encoding = iconv.encodingExists(encoding) ? encoding : DEFAULT_ENCODING;
13+
1314
return iconv.decode(Buffer.concat(buffers), encoding);
1415
}

Source/extension/common/process/logger.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export function logProcess(
2626
.map((e) => toCommandArgumentForPythonExt(trimQuotes(e)))
2727
.join(" ")
2828
: fileOrCommand;
29+
2930
const info = [`> ${getDisplayCommands(command)}`];
31+
3032
if (options && options.cwd) {
3133
info.push(
3234
`${Logging.currentWorkingDirectory} ${getDisplayCommands(options.cwd as string)}`,
@@ -40,6 +42,7 @@ export function logProcess(
4042

4143
function getDisplayCommands(command: string): string {
4244
const workspaceFolders = getWorkspaceFolders();
45+
4346
if (workspaceFolders && workspaceFolders.length === 1) {
4447
command = replaceMatchesWithCharacter(
4548
command,
@@ -48,6 +51,7 @@ function getDisplayCommands(command: string): string {
4851
);
4952
}
5053
const home = getUserHomeDir();
54+
5155
if (home) {
5256
command = replaceMatchesWithCharacter(command, home, "~");
5357
}
@@ -66,11 +70,13 @@ function replaceMatchesWithCharacter(
6670
// we need to escape using an extra backlash so it's not considered special.
6771
function getRegex(match: string) {
6872
let pattern = escapeRegExp(match);
73+
6974
if (getOSType() === OSType.Windows) {
7075
// Match both forward and backward slash versions of 'match' for Windows.
7176
pattern = replaceAll(pattern, "\\\\", "(\\\\|/)");
7277
}
7378
let regex = new RegExp(pattern, "ig");
79+
7480
return regex;
7581
}
7682

@@ -82,9 +88,12 @@ function replaceMatchesWithCharacter(
8288

8389
for (let i = 0; i < chunked.length; i++) {
8490
let regex = getRegex(match);
91+
8592
const regexResult = regex.exec(chunked[i]);
93+
8694
if (regexResult) {
8795
const regexIndex = regexResult.index;
96+
8897
if (
8998
regexIndex > 0 &&
9099
isPrevioustoMatchRegexALetter(chunked[i], regexIndex - 1)

0 commit comments

Comments
 (0)