Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"quickPickItemTooltip",
"saveEditor",
"terminalDataWriteEvent",
"terminalExecuteCommandEvent"
"terminalExecuteCommandEvent",
"handleIssueUri"
],
"author": {
"name": "Microsoft Corporation"
Expand All @@ -45,7 +46,7 @@
"theme": "dark"
},
"engines": {
"vscode": "^1.82.0"
"vscode": "^1.83.0-insider"
},
"enableTelemetry": false,
"keywords": [
Expand Down
19 changes: 1 addition & 18 deletions resources/report_issue_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ XXX
**After** creating the issue on GitHub, you can add screenshots and GIFs of what is happening. Consider tools like https://www.cockos.com/licecap/, https://github.com/phw/peek or https://www.screentogif.com/ for GIF creation.
-->

<!-- **NOTE**: Everything below except Python output panel is auto-generated; no editing required. Please do provide Python output panel. -->
<!-- **NOTE**: Please do provide Python output panel. -->
# Diagnostic data

- Python version (& distribution if applicable, e.g. Anaconda): {0}
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): {1}
- Value of the `python.languageServer` setting: {2}

<details>

<summary>Output for <code>Python</code> in the <code>Output</code> panel (<code>View</code>→<code>Output</code>, change the drop-down the upper-right of the <code>Output</code> panel to <code>Python</code>)
Expand All @@ -32,16 +28,3 @@ XXX

</p>
</details>

<details>

<summary>User Settings</summary>

<p>

```
{3}{4}
```

</p>
</details>
16 changes: 16 additions & 0 deletions resources/report_issue_user_data_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- Python version (& distribution if applicable, e.g. Anaconda): {0}
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): {1}
- Value of the `python.languageServer` setting: {2}

<details>

<summary>User Settings</summary>

<p>

```
{3}{4}
```

</p>
</details>
Original file line number Diff line number Diff line change
@@ -1,54 +1,56 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

import * as fs from 'fs-extra';
import * as os from 'os';
import * as path from 'path';
import * as os from 'os';

import { IssueDataProvider, ProviderResult, Uri, env } from 'vscode';
import { inject, injectable } from 'inversify';
import { isEqual } from 'lodash';
import { IExtensionSingleActivationService } from '../../../activation/types';
import { IApplicationEnvironment, ICommandManager, IWorkspaceService } from '../types';
import { EXTENSION_ROOT_DIR } from '../../../constants';
import { IInterpreterService } from '../../../interpreter/contracts';
import { Commands } from '../../constants';
import { IConfigurationService, IPythonSettings } from '../../types';
import { sendTelemetryEvent } from '../../../telemetry';
import { EventName } from '../../../telemetry/constants';
import { EnvironmentType } from '../../../pythonEnvironments/info';
import { PythonSettings } from '../../configSettings';
import { SystemVariables } from '../../variables/systemVariables';
import { IConfigurationService, IDisposableRegistry, IPythonSettings } from '../types';
import { EXTENSION_ROOT_DIR } from '../constants';
import { IApplicationEnvironment, IWorkspaceService } from './types';
import { IInterpreterService } from '../../interpreter/contracts';
import { EnvironmentType } from '../../pythonEnvironments/info';
import { PythonSettings } from '../configSettings';
import { SystemVariables } from '../variables/systemVariables';
import { IExtensionSingleActivationService } from '../../activation/types';

/**
* Allows the user to report an issue related to the Python extension using our template.
*/
@injectable()
export class ReportIssueCommandHandler implements IExtensionSingleActivationService {
public readonly supportedWorkspaceTypes = { untrustedWorkspace: false, virtualWorkspace: true };

export class PythonIssueDataProvider implements IssueDataProvider, IExtensionSingleActivationService {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private readonly packageJSONSettings: any;

public readonly supportedWorkspaceTypes = { untrustedWorkspace: true, virtualWorkspace: true };

constructor(
@inject(ICommandManager) private readonly commandManager: ICommandManager,
@inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService,
@inject(IInterpreterService) private readonly interpreterService: IInterpreterService,
@inject(IConfigurationService) protected readonly configurationService: IConfigurationService,
@inject(IApplicationEnvironment) appEnvironment: IApplicationEnvironment,
@inject(IDisposableRegistry) private readonly disposableRegistry: IDisposableRegistry,
) {
this.packageJSONSettings = appEnvironment.packageJson?.contributes?.configuration?.properties;
}

public async activate(): Promise<void> {
this.commandManager.registerCommand(Commands.ReportIssue, this.openReportIssue, this);
}

private argSettingsPath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_user_settings.json');

private templatePath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_template.md');

public async openReportIssue(): Promise<void> {
private userDataTemplatePath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_user_data_template.md');

public async activate(): Promise<void> {
this.disposableRegistry.push(
env.registerIssueUriRequestHandler({
handleIssueUrlRequest: () => Uri.parse('https://aka.ms/microsoft/vscode-python'),
}),
);
this.disposableRegistry.push(env.registerIssueDataProvider(this));
}

public provideIssueTemplate(): ProviderResult<string> {
return fs.readFile(this.templatePath, 'utf8').then((data) => data);
}

public async getIssueDataInfo(): Promise<string> {
const settings: IPythonSettings = this.configurationService.getSettings();
const argSettings = JSON.parse(await fs.readFile(this.argSettingsPath, 'utf8'));
let userSettings = '';
Expand Down Expand Up @@ -85,7 +87,8 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ
}
}
});
const template = await fs.readFile(this.templatePath, 'utf8');

const template = await fs.readFile(this.userDataTemplatePath, 'utf8');
const interpreter = await this.interpreterService.getActiveInterpreter();
const pythonVersion = interpreter?.version?.raw ?? '';
const languageServer =
Expand All @@ -97,17 +100,12 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ
hasMultipleFolders && userSettings !== ''
? `Multiroot scenario, following user settings may not apply:${os.EOL}`
: '';
await this.commandManager.executeCommand('workbench.action.openIssueReporter', {
extensionId: 'ms-python.python',
issueBody: template.format(
pythonVersion,
virtualEnvKind,
languageServer,
hasMultipleFoldersText,
userSettings,
),
});
sendTelemetryEvent(EventName.USE_REPORT_ISSUE_COMMAND, undefined, {});

return template.format(pythonVersion, virtualEnvKind, languageServer, hasMultipleFoldersText, userSettings);
}

public provideIssueData(): ProviderResult<string> {
return this.getIssueDataInfo().then((data) => data);
}

private getDefaultValue(settingKey: string) {
Expand Down
4 changes: 2 additions & 2 deletions src/client/common/serviceRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { ApplicationShell } from './application/applicationShell';
import { ClipboardService } from './application/clipboard';
import { CommandManager } from './application/commandManager';
import { ReloadVSCodeCommandHandler } from './application/commands/reloadCommand';
import { ReportIssueCommandHandler } from './application/commands/reportIssueCommand';
import { PythonIssueDataProvider } from './application/issueDataProvider';
import { DebugService } from './application/debugService';
import { DebugSessionTelemetry } from './application/debugSessionTelemetry';
import { DocumentManager } from './application/documentManager';
Expand Down Expand Up @@ -181,7 +181,7 @@ export function registerTypes(serviceManager: IServiceManager): void {
);
serviceManager.addSingleton<IExtensionSingleActivationService>(
IExtensionSingleActivationService,
ReportIssueCommandHandler,
PythonIssueDataProvider,
);
serviceManager.addSingleton<IExtensionSingleActivationService>(
IExtensionSingleActivationService,
Expand Down
1 change: 0 additions & 1 deletion src/client/extensionActivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
'use strict';

import { debug, DebugConfigurationProvider, DebugConfigurationProviderTriggerKind, languages, window } from 'vscode';

import { registerTypes as activationRegisterTypes } from './activation/serviceRegistry';
import { IExtensionActivationManager } from './activation/types';
import { registerTypes as appRegisterTypes } from './application/serviceRegistry';
Expand Down
56 changes: 0 additions & 56 deletions src/test/common/application/commands/issueTemplateVenv1.md

This file was deleted.

53 changes: 0 additions & 53 deletions src/test/common/application/commands/issueTemplateVenv2.md

This file was deleted.

Loading