Skip to content

Commit 1d292d8

Browse files
authored
Fix progress indicator messages (microsoft#3663)
For microsoft#3082
1 parent fe7bf71 commit 1d292d8

7 files changed

Lines changed: 22 additions & 19 deletions

File tree

package.nls.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,10 @@
133133
"DataScience.exportingFormat": "Exporting {0}",
134134
"DataScience.exportCancel": "Cancel",
135135
"Common.canceled": "Canceled",
136-
"diagnostics.progress": "Validating user setup",
137-
"LanguageService.progressActivating": "Activating Language Server",
138136
"DataScience.importChangeDirectoryComment": "#%% Change working directory from the workspace root to the ipynb file location. Turn this addition off with the DataSciece.changeDirOnImportExport setting",
139137
"DataScience.exportChangeDirectoryComment": "# Change directory to VSCode workspace root so that relative path loads work correctly. Turn this addition off with the DataSciece.changeDirOnImportExport setting",
140-
"DataScience.interruptKernelStatus" : "Interrupting iPython Kernel",
141-
"DataScience.restartKernelAfterInterruptMessage" : "Interrupting the kernel timed out. Do you want to restart the kernel instead? All variables will be lost.",
142-
"DataScience.pythonInterruptFailedHeader" : "Keyboard interrupt crashed the kernel. Kernel restarted."
138+
"DataScience.interruptKernelStatus": "Interrupting iPython Kernel",
139+
"DataScience.restartKernelAfterInterruptMessage": "Interrupting the kernel timed out. Do you want to restart the kernel instead? All variables will be lost.",
140+
"DataScience.pythonInterruptFailedHeader": "Keyboard interrupt crashed the kernel. Kernel restarted.",
141+
"Common.loadingPythonExtension": "Python extension loading..."
143142
}

src/client/activation/activationService.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import {
1818
IConfigurationService, IDisposableRegistry,
1919
IOutputChannel, IPythonSettings
2020
} from '../common/types';
21-
import { displayProgress } from '../common/utils/decorators';
22-
import { LanguageService } from '../common/utils/localize';
2321
import { IServiceContainer } from '../ioc/types';
2422
import { sendTelemetryEvent } from '../telemetry';
2523
import { PYTHON_LANGUAGE_SERVER_PLATFORM_NOT_SUPPORTED } from '../telemetry/constants';
@@ -49,7 +47,6 @@ export class ExtensionActivationService implements IExtensionActivationService,
4947
disposables.push(this);
5048
disposables.push(this.workspaceService.onDidChangeConfiguration(this.onDidChangeConfiguration.bind(this)));
5149
}
52-
@displayProgress(LanguageService.progressActivating())
5350

5451
public async activate(): Promise<void> {
5552
if (this.currentActivator) {

src/client/application/diagnostics/applicationDiagnostics.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { inject, injectable, named } from 'inversify';
77
import { DiagnosticSeverity } from 'vscode';
88
import { STANDARD_OUTPUT_CHANNEL } from '../../common/constants';
99
import { ILogger, IOutputChannel } from '../../common/types';
10-
import { displayProgress } from '../../common/utils/decorators';
11-
import { Diagnostics } from '../../common/utils/localize';
1210
import { IServiceContainer } from '../../ioc/types';
1311
import { IApplicationDiagnostics } from '../types';
1412
import { IDiagnostic, IDiagnosticsService, ISourceMapSupportService } from './types';
@@ -20,7 +18,6 @@ export class ApplicationDiagnostics implements IApplicationDiagnostics {
2018
public register() {
2119
this.serviceContainer.get<ISourceMapSupportService>(ISourceMapSupportService).register();
2220
}
23-
@displayProgress(Diagnostics.progress())
2421
public async performPreStartupHealthCheck(): Promise<void> {
2522
const diagnosticsServices = this.serviceContainer.getAll<IDiagnosticsService>(IDiagnosticsService);
2623
await Promise.all(diagnosticsServices.map(async diagnosticsService => {

src/client/common/utils/localize.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { EXTENSION_ROOT_DIR } from '../../constants';
99

1010
// External callers of localize use these tables to retrieve localized values.
1111
export namespace Diagnostics {
12-
export const progress = localize('diagnostics.progress', 'Validating user setup');
1312
export const warnSourceMaps = localize('diagnostics.warnSourceMaps', 'Source map support is enabled in the Python Extension, this will adversely impact performance of the extension.');
1413
export const disableSourceMaps = localize('diagnostics.disableSourceMaps', 'Disable Source Map Support');
1514
export const warnBeforeEnablingSourceMaps = localize('diagnostics.warnBeforeEnablingSourceMaps', 'Enabling source map support in the Python Extension will adversely impact performance of the extension.');
@@ -18,13 +17,13 @@ export namespace Diagnostics {
1817

1918
export namespace Common {
2019
export const canceled = localize('Common.canceled', 'Canceled');
20+
export const loadingExtension = localize('Common.loadingPythonExtension', 'Python extension loading...');
2121
}
2222

2323
export namespace LanguageService {
2424
export const bannerMessage = localize('LanguageService.bannerMessage', 'Can you please take 2 minutes to tell us how the Python Language Server is working for you?');
2525
export const bannerLabelYes = localize('LanguageService.bannerLabelYes', 'Yes, take survey now');
2626
export const bannerLabelNo = localize('LanguageService.bannerLabelNo', 'No, thanks');
27-
export const progressActivating = localize('LanguageService.progressActivating', 'Activating Language Server');
2827
}
2928

3029
export namespace Interpreters {

src/client/extension.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import {
2121
languages,
2222
Memento,
2323
OutputChannel,
24+
ProgressLocation,
25+
ProgressOptions,
2426
window
2527
} from 'vscode';
2628

@@ -51,6 +53,7 @@ import {
5153
WORKSPACE_MEMENTO
5254
} from './common/types';
5355
import { createDeferred } from './common/utils/async';
56+
import { Common } from './common/utils/localize';
5457
import { registerTypes as variableRegisterTypes } from './common/variables/serviceRegistry';
5558
import { registerTypes as dataScienceRegisterTypes } from './datascience/serviceRegistry';
5659
import { IDataScience } from './datascience/types';
@@ -97,6 +100,7 @@ let activatedServiceContainer: ServiceContainer | undefined;
97100

98101
// tslint:disable-next-line:max-func-body-length
99102
export async function activate(context: ExtensionContext): Promise<IExtensionApi> {
103+
displayProgress(activationDeferred.promise);
100104
durations.startActivateTime = stopWatch.elapsedTime;
101105
const cont = new Container();
102106
const serviceManager = new ServiceManager(cont);
@@ -123,6 +127,7 @@ export async function activate(context: ExtensionContext): Promise<IExtensionApi
123127

124128
const activationService = serviceContainer.get<IExtensionActivationService>(IExtensionActivationService);
125129
const lsActivationPromise = activationService.activate();
130+
displayProgress(lsActivationPromise);
126131

127132
const sortImports = serviceContainer.get<ISortImportsEditingProvider>(ISortImportsEditingProvider);
128133
sortImports.registerCommands();
@@ -213,6 +218,12 @@ export function deactivate(): Thenable<void> {
213218
return Promise.resolve();
214219
}
215220

221+
// tslint:disable-next-line:no-any
222+
function displayProgress(promise: Promise<any>) {
223+
const progressOptions: ProgressOptions = { location: ProgressLocation.Window, title: Common.loadingExtension() };
224+
window.withProgress(progressOptions, () => promise);
225+
}
226+
216227
function registerServices(context: ExtensionContext, serviceManager: ServiceManager, serviceContainer: ServiceContainer) {
217228
serviceManager.addSingletonInstance<IServiceContainer>(IServiceContainer, serviceContainer);
218229
serviceManager.addSingletonInstance<IServiceManager>(IServiceManager, serviceManager);

src/client/interpreter/display/progressDisplay.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { IApplicationShell } from '../../common/application/types';
99
import { traceDecorators } from '../../common/logger';
1010
import { IDisposableRegistry } from '../../common/types';
1111
import { createDeferred, Deferred } from '../../common/utils/async';
12-
import { Interpreters } from '../../common/utils/localize';
12+
import { Common, Interpreters } from '../../common/utils/localize';
1313
import { IInterpreterLocatorProgressService, InterpreterLocatorProgressHandler } from '../contracts';
1414

1515
@injectable()
@@ -39,7 +39,7 @@ export class InterpreterLocatorProgressStatubarHandler implements InterpreterLoc
3939
private createProgress() {
4040
const progressOptions: ProgressOptions = {
4141
location: ProgressLocation.Window,
42-
title: this.isFirstTimeLoadingInterpreters ? Interpreters.loading() : Interpreters.refreshing()
42+
title: this.isFirstTimeLoadingInterpreters ? Common.loadingExtension() : Interpreters.refreshing()
4343
};
4444
this.isFirstTimeLoadingInterpreters = false;
4545
this.shell.withProgress(progressOptions, () => {

src/test/interpreters/display/progressDisplay.unit.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { expect } from 'chai';
99
import { anything, capture, instance, mock, when } from 'ts-mockito';
1010
import { CancellationToken, Disposable, Progress, ProgressOptions } from 'vscode';
1111
import { ApplicationShell } from '../../../client/common/application/applicationShell';
12-
import { Interpreters } from '../../../client/common/utils/localize';
12+
import { Common, Interpreters } from '../../../client/common/utils/localize';
1313
import { noop } from '../../../client/common/utils/misc';
1414
import { IInterpreterLocatorProgressService } from '../../../client/interpreter/contracts';
1515
import { InterpreterLocatorProgressStatubarHandler } from '../../../client/interpreter/display/progressDisplay';
@@ -42,7 +42,7 @@ suite('Interpreters - Display Progress', () => {
4242
refreshingCallback(undefined);
4343

4444
const options = capture(shell.withProgress as any).last()[0] as ProgressOptions;
45-
expect(options.title).to.be.equal(Interpreters.loading());
45+
expect(options.title).to.be.equal(Common.loadingExtension());
4646
});
4747

4848
test('Display refreshing message when refreshing interpreters for the second time', async () => {
@@ -54,7 +54,7 @@ suite('Interpreters - Display Progress', () => {
5454
refreshingCallback(undefined);
5555

5656
let options = capture(shell.withProgress as any).last()[0] as ProgressOptions;
57-
expect(options.title).to.be.equal(Interpreters.loading());
57+
expect(options.title).to.be.equal(Common.loadingExtension());
5858

5959
refreshingCallback(undefined);
6060

@@ -74,7 +74,7 @@ suite('Interpreters - Display Progress', () => {
7474
const callback = capture(shell.withProgress as any).last()[1] as ProgressTask<void>;
7575
const promise = callback(undefined as any, undefined as any);
7676

77-
expect(options.title).to.be.equal(Interpreters.loading());
77+
expect(options.title).to.be.equal(Common.loadingExtension());
7878

7979
refreshedCallback(undefined);
8080
// Promise must resolve when refreshed callback is invoked.

0 commit comments

Comments
 (0)