diff --git a/src/vs/editor/contrib/codeAction/codeActionCommands.ts b/src/vs/editor/contrib/codeAction/codeActionCommands.ts index fbf4917b1355191add1ebe4a1d74959c3ebba863..dbe2c21364708ca8c613818e8d8eff5f8561fecb 100644 --- a/src/vs/editor/contrib/codeAction/codeActionCommands.ts +++ b/src/vs/editor/contrib/codeAction/codeActionCommands.ts @@ -19,7 +19,7 @@ import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/commo import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IMarkerService } from 'vs/platform/markers/common/markers'; -import { ILocalProgressService } from 'vs/platform/progress/common/progress'; +import { IEditorProgressService } from 'vs/platform/progress/common/progress'; import { CodeActionModel, SUPPORTED_CODE_ACTIONS, CodeActionsState } from './codeActionModel'; import { CodeActionAutoApply, CodeActionFilter, CodeActionKind, CodeActionTrigger } from './codeActionTrigger'; import { CodeActionWidget } from './codeActionWidget'; @@ -52,7 +52,7 @@ export class QuickFixController extends Disposable implements IEditorContributio editor: ICodeEditor, @IMarkerService markerService: IMarkerService, @IContextKeyService contextKeyService: IContextKeyService, - @ILocalProgressService progressService: ILocalProgressService, + @IEditorProgressService progressService: IEditorProgressService, @IContextMenuService contextMenuService: IContextMenuService, @ICommandService private readonly _commandService: ICommandService, @IKeybindingService private readonly _keybindingService: IKeybindingService, diff --git a/src/vs/editor/contrib/codeAction/codeActionModel.ts b/src/vs/editor/contrib/codeAction/codeActionModel.ts index 8b6cc5a48632bb8270b2346f65fbb2140a0cd074..7e71c64133ddaf3075481d9ac1be85dd93ff2b08 100644 --- a/src/vs/editor/contrib/codeAction/codeActionModel.ts +++ b/src/vs/editor/contrib/codeAction/codeActionModel.ts @@ -14,7 +14,7 @@ import { Selection } from 'vs/editor/common/core/selection'; import { CodeActionProviderRegistry } from 'vs/editor/common/modes'; import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IMarkerService } from 'vs/platform/markers/common/markers'; -import { ILocalProgressService } from 'vs/platform/progress/common/progress'; +import { IEditorProgressService } from 'vs/platform/progress/common/progress'; import { getCodeActions, CodeActionSet } from './codeAction'; import { CodeActionTrigger } from './codeActionTrigger'; @@ -167,7 +167,7 @@ export class CodeActionModel extends Disposable { private readonly _editor: ICodeEditor, private readonly _markerService: IMarkerService, contextKeyService: IContextKeyService, - private readonly _progressService?: ILocalProgressService + private readonly _progressService?: IEditorProgressService ) { super(); this._supportedCodeActions = SUPPORTED_CODE_ACTIONS.bindTo(contextKeyService); diff --git a/src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts b/src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts index bf6e607945c09362ade19a95b65a6b83e2fe26cf..baad3f0bb171380c4a0cf50171f51906d2d45eed 100644 --- a/src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts +++ b/src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts @@ -25,7 +25,7 @@ import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { INotificationService } from 'vs/platform/notification/common/notification'; -import { ILocalProgressService } from 'vs/platform/progress/common/progress'; +import { IEditorProgressService } from 'vs/platform/progress/common/progress'; import { getDefinitionsAtPosition, getImplementationsAtPosition, getTypeDefinitionsAtPosition, getDeclarationsAtPosition } from './goToDefinition'; import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { EditorStateCancellationTokenSource, CodeEditorStateFlag } from 'vs/editor/browser/core/editorState'; @@ -58,7 +58,7 @@ export class DefinitionAction extends EditorAction { } const notificationService = accessor.get(INotificationService); const editorService = accessor.get(ICodeEditorService); - const progressService = accessor.get(ILocalProgressService); + const progressService = accessor.get(IEditorProgressService); const symbolNavService = accessor.get(ISymbolNavigationService); const model = editor.getModel(); diff --git a/src/vs/editor/contrib/rename/rename.ts b/src/vs/editor/contrib/rename/rename.ts index 28ec66cfaf792c08875106f3e052b63552b890e6..ab06982895bef7cb1baea4bd545ecdd93187f157 100644 --- a/src/vs/editor/contrib/rename/rename.ts +++ b/src/vs/editor/contrib/rename/rename.ts @@ -7,7 +7,7 @@ import * as nls from 'vs/nls'; import { illegalArgument, onUnexpectedError } from 'vs/base/common/errors'; import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; import { IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; -import { ILocalProgressService } from 'vs/platform/progress/common/progress'; +import { IEditorProgressService } from 'vs/platform/progress/common/progress'; import { registerEditorAction, registerEditorContribution, ServicesAccessor, EditorAction, EditorCommand, registerEditorCommand, registerDefaultLanguageCommand } from 'vs/editor/browser/editorExtensions'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; import { ITextModel } from 'vs/editor/common/model'; @@ -114,7 +114,7 @@ class RenameController extends Disposable implements IEditorContribution { private readonly editor: ICodeEditor, @INotificationService private readonly _notificationService: INotificationService, @IBulkEditService private readonly _bulkEditService: IBulkEditService, - @ILocalProgressService private readonly _progressService: ILocalProgressService, + @IEditorProgressService private readonly _progressService: IEditorProgressService, @IContextKeyService private readonly _contextKeyService: IContextKeyService, @IThemeService private readonly _themeService: IThemeService, ) { diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index 1f44f24648608b03bd147d8700d5ddfef48d8efe..56a0f094d6e4ffea9541f03ccf6a26231e7fc5c7 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -38,7 +38,7 @@ import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKe import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding'; import { ILabelService, ResourceLabelFormatter } from 'vs/platform/label/common/label'; import { INotification, INotificationHandle, INotificationService, IPromptChoice, IPromptOptions, NoOpNotification, IStatusMessageOptions } from 'vs/platform/notification/common/notification'; -import { IProgressRunner, ILocalProgressService } from 'vs/platform/progress/common/progress'; +import { IProgressRunner, IEditorProgressService } from 'vs/platform/progress/common/progress'; import { ITelemetryInfo, ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IWorkspace, IWorkspaceContextService, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, WorkbenchState, WorkspaceFolder } from 'vs/platform/workspace/common/workspace'; import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; @@ -137,7 +137,7 @@ export class SimpleEditorModelResolverService implements ITextModelService { } } -export class SimpleLocalProgressService implements ILocalProgressService { +export class SimpleEditorProgressService implements IEditorProgressService { _serviceBrand: any; private static NULL_PROGRESS_RUNNER: IProgressRunner = { @@ -149,7 +149,7 @@ export class SimpleLocalProgressService implements ILocalProgressService { show(infinite: true, delay?: number): IProgressRunner; show(total: number, delay?: number): IProgressRunner; show(): IProgressRunner { - return SimpleLocalProgressService.NULL_PROGRESS_RUNNER; + return SimpleEditorProgressService.NULL_PROGRESS_RUNNER; } showWhile(promise: Promise, delay?: number): Promise { diff --git a/src/vs/editor/standalone/browser/standaloneServices.ts b/src/vs/editor/standalone/browser/standaloneServices.ts index 79277379d5e8e2a163938d43dd10685e98dcf516..996798d3d6a09e8ec9e74969a7aca6a0218bf48e 100644 --- a/src/vs/editor/standalone/browser/standaloneServices.ts +++ b/src/vs/editor/standalone/browser/standaloneServices.ts @@ -13,7 +13,7 @@ import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl'; import { IModelService } from 'vs/editor/common/services/modelService'; import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl'; import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; -import { SimpleBulkEditService, SimpleConfigurationService, SimpleDialogService, SimpleNotificationService, SimpleLocalProgressService, SimpleResourceConfigurationService, SimpleResourcePropertiesService, SimpleUriLabelService, SimpleWorkspaceContextService, StandaloneCommandService, StandaloneKeybindingService, StandaloneTelemetryService, SimpleLayoutService } from 'vs/editor/standalone/browser/simpleServices'; +import { SimpleBulkEditService, SimpleConfigurationService, SimpleDialogService, SimpleNotificationService, SimpleEditorProgressService, SimpleResourceConfigurationService, SimpleResourcePropertiesService, SimpleUriLabelService, SimpleWorkspaceContextService, StandaloneCommandService, StandaloneKeybindingService, StandaloneTelemetryService, SimpleLayoutService } from 'vs/editor/standalone/browser/simpleServices'; import { StandaloneCodeEditorServiceImpl } from 'vs/editor/standalone/browser/standaloneCodeServiceImpl'; import { StandaloneThemeServiceImpl } from 'vs/editor/standalone/browser/standaloneThemeServiceImpl'; import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService'; @@ -36,7 +36,7 @@ import { ILogService, NullLogService } from 'vs/platform/log/common/log'; import { MarkerService } from 'vs/platform/markers/common/markerService'; import { IMarkerService } from 'vs/platform/markers/common/markers'; import { INotificationService } from 'vs/platform/notification/common/notification'; -import { ILocalProgressService } from 'vs/platform/progress/common/progress'; +import { IEditorProgressService } from 'vs/platform/progress/common/progress'; import { IStorageService, InMemoryStorageService } from 'vs/platform/storage/common/storage'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService } from 'vs/platform/theme/common/themeService'; @@ -154,7 +154,7 @@ export module StaticServices { export const codeEditorService = define(ICodeEditorService, (o) => new StandaloneCodeEditorServiceImpl(standaloneThemeService.get(o))); - export const localProgressService = define(ILocalProgressService, () => new SimpleLocalProgressService()); + export const editorProgressService = define(IEditorProgressService, () => new SimpleEditorProgressService()); export const storageService = define(IStorageService, () => new InMemoryStorageService()); diff --git a/src/vs/platform/progress/common/progress.ts b/src/vs/platform/progress/common/progress.ts index 1e1162f640fc7746ad6588a74c04303181599f4b..634b38b1929b2d3f5ec2c9c4db3a52e6fcbac457 100644 --- a/src/vs/platform/progress/common/progress.ts +++ b/src/vs/platform/progress/common/progress.ts @@ -20,15 +20,7 @@ export interface IProgressService { withProgress(options: IProgressOptions | IProgressNotificationOptions | IProgressCompositeOptions, task: (progress: IProgress) => Promise, onDidCancel?: () => void): Promise; } -export const ILocalProgressService = createDecorator('localProgressService'); - -/** - * A progress service that will report progress local to the UI piece triggered from. E.g. - * if used from an action of a viewlet, the progress will be reported in that viewlet. - */ -export interface ILocalProgressService { - - _serviceBrand: ServiceIdentifier; +export interface IProgressIndicator { /** * Show progress customized with the provided flags. @@ -132,7 +124,7 @@ export class LongRunningOperation extends Disposable { private currentProgressTimeout: any; constructor( - private localProgressService: ILocalProgressService + private progressIndicator: IProgressIndicator ) { super(); } @@ -147,7 +139,7 @@ export class LongRunningOperation extends Disposable { const newOperationToken = new CancellationTokenSource(); this.currentProgressTimeout = setTimeout(() => { if (newOperationId === this.currentOperationId) { - this.currentProgressRunner = this.localProgressService.show(true); + this.currentProgressRunner = this.progressIndicator.show(true); } }, progressDelay); @@ -173,3 +165,13 @@ export class LongRunningOperation extends Disposable { } } } + +export const IEditorProgressService = createDecorator('editorProgressService'); + +/** + * A progress service that will report progress local to the editor triggered from. + */ +export interface IEditorProgressService extends IProgressIndicator { + + _serviceBrand: ServiceIdentifier; +} diff --git a/src/vs/workbench/browser/parts/compositePart.ts b/src/vs/workbench/browser/parts/compositePart.ts index 8be3d84e29ea3924d32adbd2fcd8d4f4609781b0..7b10d5f06c5abcee2ee613b076d61456f5c1a3e5 100644 --- a/src/vs/workbench/browser/parts/compositePart.ts +++ b/src/vs/workbench/browser/parts/compositePart.ts @@ -18,13 +18,12 @@ import { IAction } from 'vs/base/common/actions'; import { Part, IPartOptions } from 'vs/workbench/browser/part'; import { Composite, CompositeRegistry } from 'vs/workbench/browser/composite'; import { IComposite } from 'vs/workbench/common/composite'; -import { ScopedProgressService } from 'vs/workbench/services/progress/browser/localProgressService'; +import { CompositeProgressIndicator } from 'vs/workbench/services/progress/browser/progressIndicator'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; -import { ILocalProgressService } from 'vs/platform/progress/common/progress'; +import { IProgressIndicator } from 'vs/platform/progress/common/progress'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IThemeService } from 'vs/platform/theme/common/themeService'; @@ -50,7 +49,7 @@ export interface ICompositeTitleLabel { interface CompositeItem { composite: Composite; disposable: IDisposable; - localProgressService: ILocalProgressService; + progress: IProgressIndicator; } export abstract class CompositePart extends Part { @@ -169,17 +168,18 @@ export abstract class CompositePart extends Part { // Instantiate composite from registry otherwise const compositeDescriptor = this.registry.getComposite(id); if (compositeDescriptor) { - const localProgressService = this.instantiationService.createInstance(ScopedProgressService, this.progressBar, compositeDescriptor.id, isActive); - const compositeInstantiationService = this.instantiationService.createChild(new ServiceCollection([ILocalProgressService, localProgressService])); - - const composite = compositeDescriptor.instantiate(compositeInstantiationService); - const disposables = new DisposableStore(); + const composite = compositeDescriptor.instantiate(this.instantiationService); + const disposable = new DisposableStore(); // Remember as Instantiated - this.instantiatedCompositeItems.set(id, { composite, disposable: disposables, localProgressService }); + this.instantiatedCompositeItems.set(id, { + composite, + disposable, + progress: this._register(this.instantiationService.createInstance(CompositeProgressIndicator, this.progressBar, compositeDescriptor.id, isActive)) + }); // Register to title area update events from the composite - disposables.add(composite.onTitleAreaUpdate(() => this.onTitleAreaUpdate(composite.getId()), this)); + disposable.add(composite.onTitleAreaUpdate(() => this.onTitleAreaUpdate(composite.getId()), this)); return composite; } @@ -451,10 +451,10 @@ export abstract class CompositePart extends Part { return contentContainer; } - getProgressIndicator(id: string): ILocalProgressService | null { + getProgressIndicator(id: string): IProgressIndicator | null { const compositeItem = this.instantiatedCompositeItems.get(id); - return compositeItem ? compositeItem.localProgressService : null; + return compositeItem ? compositeItem.progress : null; } protected getActions(): ReadonlyArray { diff --git a/src/vs/workbench/browser/parts/editor/editorControl.ts b/src/vs/workbench/browser/parts/editor/editorControl.ts index a3c50f7011ae89b52d2df632cccf20e48e3b2014..646ecb46f2c764f709754bd11c4b6c52fd2f325f 100644 --- a/src/vs/workbench/browser/parts/editor/editorControl.ts +++ b/src/vs/workbench/browser/parts/editor/editorControl.ts @@ -11,7 +11,7 @@ import { IEditorRegistry, Extensions as EditorExtensions, IEditorDescriptor } fr import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { ILocalProgressService, LongRunningOperation } from 'vs/platform/progress/common/progress'; +import { IEditorProgressService, LongRunningOperation } from 'vs/platform/progress/common/progress'; import { IEditorGroupView, DEFAULT_EDITOR_MIN_DIMENSIONS, DEFAULT_EDITOR_MAX_DIMENSIONS } from 'vs/workbench/browser/parts/editor/editor'; import { Event, Emitter } from 'vs/base/common/event'; import { IVisibleEditor } from 'vs/workbench/services/editor/common/editorService'; @@ -47,11 +47,11 @@ export class EditorControl extends Disposable { private groupView: IEditorGroupView, @IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService, @IInstantiationService private readonly instantiationService: IInstantiationService, - @ILocalProgressService localProgressService: ILocalProgressService + @IEditorProgressService editorProgressService: IEditorProgressService ) { super(); - this.editorOperation = this._register(new LongRunningOperation(localProgressService)); + this.editorOperation = this._register(new LongRunningOperation(editorProgressService)); } get activeControl(): IVisibleEditor | null { diff --git a/src/vs/workbench/browser/parts/editor/editorGroupView.ts b/src/vs/workbench/browser/parts/editor/editorGroupView.ts index 5aa9e32bb4bcaafbd5d5a45a01a3ab8352c4dd9d..323f41a55cbf30869de3dfad412a0bdb4082cfb2 100644 --- a/src/vs/workbench/browser/parts/editor/editorGroupView.ts +++ b/src/vs/workbench/browser/parts/editor/editorGroupView.ts @@ -20,8 +20,8 @@ import { Themable, EDITOR_GROUP_HEADER_TABS_BORDER, EDITOR_GROUP_HEADER_TABS_BAC import { IMoveEditorOptions, ICopyEditorOptions, ICloseEditorsFilter, IGroupChangeEvent, GroupChangeKind, EditorsOrder, GroupsOrder, ICloseEditorOptions } from 'vs/workbench/services/editor/common/editorGroupsService'; import { TabsTitleControl } from 'vs/workbench/browser/parts/editor/tabsTitleControl'; import { EditorControl } from 'vs/workbench/browser/parts/editor/editorControl'; -import { ILocalProgressService } from 'vs/platform/progress/common/progress'; -import { LocalProgressService } from 'vs/workbench/services/progress/browser/localProgressService'; +import { IEditorProgressService } from 'vs/platform/progress/common/progress'; +import { EditorProgressService } from 'vs/workbench/services/progress/browser/editorProgressService'; import { localize } from 'vs/nls'; import { isPromiseCanceledError } from 'vs/base/common/errors'; import { dispose, MutableDisposable } from 'vs/base/common/lifecycle'; @@ -178,7 +178,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { const scopedContextKeyService = this._register(this.contextKeyService.createScoped(this.element)); this.scopedInstantiationService = this.instantiationService.createChild(new ServiceCollection( [IContextKeyService, scopedContextKeyService], - [ILocalProgressService, new LocalProgressService(this.progressBar)] + [IEditorProgressService, new EditorProgressService(this.progressBar)] )); // Context keys diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts b/src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts index 2600517f9b181b7dc6e259c599870e6ebc8e1080..6912a5f72a6397f18d9af6e174b5d112b9540418 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts @@ -31,7 +31,7 @@ import { ConfigurationTarget } from 'vs/platform/configuration/common/configurat import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ILogService } from 'vs/platform/log/common/log'; -import { ILocalProgressService } from 'vs/platform/progress/common/progress'; +import { IEditorProgressService } from 'vs/platform/progress/common/progress'; import { Registry } from 'vs/platform/registry/common/platform'; import { IStorageService } from 'vs/platform/storage/common/storage'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; @@ -94,7 +94,7 @@ export class PreferencesEditor extends BaseEditor { @IContextKeyService private readonly contextKeyService: IContextKeyService, @IInstantiationService private readonly instantiationService: IInstantiationService, @IThemeService themeService: IThemeService, - @ILocalProgressService private readonly progressService: ILocalProgressService, + @IEditorProgressService private readonly editorProgressService: IEditorProgressService, @IStorageService storageService: IStorageService ) { super(PreferencesEditor.ID, telemetryService, themeService, storageService); @@ -237,7 +237,7 @@ export class PreferencesEditor extends BaseEditor { if (query) { return Promise.all([ this.localSearchDelayer.trigger(() => this.preferencesRenderers.localFilterPreferences(query).then(() => { })), - this.remoteSearchThrottle.trigger(() => Promise.resolve(this.progressService.showWhile(this.preferencesRenderers.remoteSearchPreferences(query), 500))) + this.remoteSearchThrottle.trigger(() => Promise.resolve(this.editorProgressService.showWhile(this.preferencesRenderers.remoteSearchPreferences(query), 500))) ]).then(() => { }); } else { // When clearing the input, update immediately to clear it diff --git a/src/vs/workbench/services/panel/common/panelService.ts b/src/vs/workbench/services/panel/common/panelService.ts index 501f6f8df8cc4a372d40057bd71e05cfdcfd967f..9e957d61747bb1d47c2176c8b938d2e9a24b6b7c 100644 --- a/src/vs/workbench/services/panel/common/panelService.ts +++ b/src/vs/workbench/services/panel/common/panelService.ts @@ -8,7 +8,7 @@ import { IPanel } from 'vs/workbench/common/panel'; import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation'; import { IBadge } from 'vs/workbench/services/activity/common/activity'; import { IDisposable } from 'vs/base/common/lifecycle'; -import { ILocalProgressService } from 'vs/platform/progress/common/progress'; +import { IProgressIndicator } from 'vs/platform/progress/common/progress'; export const IPanelService = createDecorator('panelService'); @@ -53,7 +53,7 @@ export interface IPanelService { /** * Returns the progress indicator for the panel bar. */ - getProgressIndicator(id: string): ILocalProgressService | null; + getProgressIndicator(id: string): IProgressIndicator | null; /** * Show an activity in a panel. diff --git a/src/vs/workbench/services/progress/browser/editorProgressService.ts b/src/vs/workbench/services/progress/browser/editorProgressService.ts new file mode 100644 index 0000000000000000000000000000000000000000..7ea3daae18ebd70a1b94cb45c5dd3a325b765f07 --- /dev/null +++ b/src/vs/workbench/services/progress/browser/editorProgressService.ts @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { IEditorProgressService } from 'vs/platform/progress/common/progress'; +import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation'; +import { ProgressBarIndicator } from 'vs/workbench/services/progress/browser/progressIndicator'; + +export class EditorProgressService extends ProgressBarIndicator { + + _serviceBrand: ServiceIdentifier; +} diff --git a/src/vs/workbench/services/progress/browser/localProgressService.ts b/src/vs/workbench/services/progress/browser/progressIndicator.ts similarity index 74% rename from src/vs/workbench/services/progress/browser/localProgressService.ts rename to src/vs/workbench/services/progress/browser/progressIndicator.ts index 2f2932873d730a8df868af9379d3671ab169c385..1d11c084f7ce5f9be99ae886cbe42e92330aacb3 100644 --- a/src/vs/workbench/services/progress/browser/localProgressService.ts +++ b/src/vs/workbench/services/progress/browser/progressIndicator.ts @@ -4,14 +4,58 @@ *--------------------------------------------------------------------------------------------*/ import { Disposable } from 'vs/base/common/lifecycle'; -import * as types from 'vs/base/common/types'; +import { isUndefinedOrNull } from 'vs/base/common/types'; import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; -import { ILocalProgressService, IProgressRunner } from 'vs/platform/progress/common/progress'; -import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation'; +import { IProgressRunner, IProgressIndicator } from 'vs/platform/progress/common/progress'; -namespace ProgressState { +export class ProgressBarIndicator implements IProgressIndicator { + + constructor(private progressbar: ProgressBar) { } + + show(infinite: true, delay?: number): IProgressRunner; + show(total: number, delay?: number): IProgressRunner; + show(infiniteOrTotal: true | number, delay?: number): IProgressRunner { + if (typeof infiniteOrTotal === 'boolean') { + this.progressbar.infinite().show(delay); + } else { + this.progressbar.total(infiniteOrTotal).show(delay); + } + + return { + total: (total: number) => { + this.progressbar.total(total); + }, + + worked: (worked: number) => { + if (this.progressbar.hasTotal()) { + this.progressbar.worked(worked); + } else { + this.progressbar.infinite().show(); + } + }, + + done: () => { + this.progressbar.stop().hide(); + } + }; + } + + async showWhile(promise: Promise, delay?: number): Promise { + try { + this.progressbar.infinite().show(delay); + + await promise; + } catch (error) { + // ignore + } finally { + this.progressbar.stop().hide(); + } + } +} + +namespace ProgressIndicatorState { export const enum Type { None, @@ -52,7 +96,7 @@ namespace ProgressState { | Work; } -export abstract class ScopedService extends Disposable { +export abstract class CompositeScope extends Disposable { constructor( private viewletService: IViewletService, @@ -89,13 +133,10 @@ export abstract class ScopedService extends Disposable { abstract onScopeDeactivated(): void; } -export class ScopedProgressService extends ScopedService implements ILocalProgressService { - - _serviceBrand: ServiceIdentifier; - +export class CompositeProgressIndicator extends CompositeScope implements IProgressIndicator { private isActive: boolean; private progressbar: ProgressBar; - private progressState: ProgressState.State = ProgressState.None; + private progressState: ProgressIndicatorState.State = ProgressIndicatorState.None; constructor( progressbar: ProgressBar, @@ -107,7 +148,7 @@ export class ScopedProgressService extends ScopedService implements ILocalProgre super(viewletService, panelService, scopeId); this.progressbar = progressbar; - this.isActive = isActive || types.isUndefinedOrNull(scopeId); // If service is unscoped, enable by default + this.isActive = isActive || isUndefinedOrNull(scopeId); // If service is unscoped, enable by default } onScopeDeactivated(): void { @@ -118,12 +159,12 @@ export class ScopedProgressService extends ScopedService implements ILocalProgre this.isActive = true; // Return early if progress state indicates that progress is done - if (this.progressState.type === ProgressState.Done.type) { + if (this.progressState.type === ProgressIndicatorState.Done.type) { return; } // Replay Infinite Progress from Promise - if (this.progressState.type === ProgressState.Type.While) { + if (this.progressState.type === ProgressIndicatorState.Type.While) { let delay: number | undefined; if (this.progressState.whileDelay > 0) { const remainingDelay = this.progressState.whileDelay - (Date.now() - this.progressState.whileStart); @@ -136,12 +177,12 @@ export class ScopedProgressService extends ScopedService implements ILocalProgre } // Replay Infinite Progress - else if (this.progressState.type === ProgressState.Type.Infinite) { + else if (this.progressState.type === ProgressIndicatorState.Type.Infinite) { this.progressbar.infinite().show(); } // Replay Finite Progress (Total & Worked) - else if (this.progressState.type === ProgressState.Type.Work) { + else if (this.progressState.type === ProgressIndicatorState.Type.Work) { if (this.progressState.total) { this.progressbar.total(this.progressState.total).show(); } @@ -158,30 +199,30 @@ export class ScopedProgressService extends ScopedService implements ILocalProgre // Sort out Arguments if (typeof infiniteOrTotal === 'boolean') { - this.progressState = ProgressState.Infinite; + this.progressState = ProgressIndicatorState.Infinite; } else { - this.progressState = new ProgressState.Work(infiniteOrTotal, undefined); + this.progressState = new ProgressIndicatorState.Work(infiniteOrTotal, undefined); } // Active: Show Progress if (this.isActive) { // Infinite: Start Progressbar and Show after Delay - if (this.progressState.type === ProgressState.Type.Infinite) { + if (this.progressState.type === ProgressIndicatorState.Type.Infinite) { this.progressbar.infinite().show(delay); } // Finite: Start Progressbar and Show after Delay - else if (this.progressState.type === ProgressState.Type.Work && typeof this.progressState.total === 'number') { + else if (this.progressState.type === ProgressIndicatorState.Type.Work && typeof this.progressState.total === 'number') { this.progressbar.total(this.progressState.total).show(delay); } } return { total: (total: number) => { - this.progressState = new ProgressState.Work( + this.progressState = new ProgressIndicatorState.Work( total, - this.progressState.type === ProgressState.Type.Work ? this.progressState.worked : undefined); + this.progressState.type === ProgressIndicatorState.Type.Work ? this.progressState.worked : undefined); if (this.isActive) { this.progressbar.total(total); @@ -192,9 +233,9 @@ export class ScopedProgressService extends ScopedService implements ILocalProgre // Verify first that we are either not active or the progressbar has a total set if (!this.isActive || this.progressbar.hasTotal()) { - this.progressState = new ProgressState.Work( - this.progressState.type === ProgressState.Type.Work ? this.progressState.total : undefined, - this.progressState.type === ProgressState.Type.Work && typeof this.progressState.worked === 'number' ? this.progressState.worked + worked : worked); + this.progressState = new ProgressIndicatorState.Work( + this.progressState.type === ProgressIndicatorState.Type.Work ? this.progressState.total : undefined, + this.progressState.type === ProgressIndicatorState.Type.Work && typeof this.progressState.worked === 'number' ? this.progressState.worked + worked : worked); if (this.isActive) { this.progressbar.worked(worked); @@ -203,13 +244,13 @@ export class ScopedProgressService extends ScopedService implements ILocalProgre // Otherwise the progress bar does not support worked(), we fallback to infinite() progress else { - this.progressState = ProgressState.Infinite; + this.progressState = ProgressIndicatorState.Infinite; this.progressbar.infinite().show(); } }, done: () => { - this.progressState = ProgressState.Done; + this.progressState = ProgressIndicatorState.Done; if (this.isActive) { this.progressbar.stop().hide(); @@ -221,12 +262,12 @@ export class ScopedProgressService extends ScopedService implements ILocalProgre async showWhile(promise: Promise, delay?: number): Promise { // Join with existing running promise to ensure progress is accurate - if (this.progressState.type === ProgressState.Type.While) { + if (this.progressState.type === ProgressIndicatorState.Type.While) { promise = Promise.all([promise, this.progressState.whilePromise]); } // Keep Promise in State - this.progressState = new ProgressState.While(promise, delay || 0, Date.now()); + this.progressState = new ProgressIndicatorState.While(promise, delay || 0, Date.now()); try { this.doShowWhile(delay); @@ -237,10 +278,10 @@ export class ScopedProgressService extends ScopedService implements ILocalProgre } finally { // If this is not the last promise in the list of joined promises, skip this - if (this.progressState.type !== ProgressState.Type.While || this.progressState.whilePromise === promise) { + if (this.progressState.type !== ProgressIndicatorState.Type.While || this.progressState.whilePromise === promise) { // The while promise is either null or equal the promise we last hooked on - this.progressState = ProgressState.None; + this.progressState = ProgressIndicatorState.None; if (this.isActive) { this.progressbar.stop().hide(); @@ -257,50 +298,3 @@ export class ScopedProgressService extends ScopedService implements ILocalProgre } } } - -export class LocalProgressService implements ILocalProgressService { - - _serviceBrand: ServiceIdentifier; - - constructor(private progressbar: ProgressBar) { } - - show(infinite: true, delay?: number): IProgressRunner; - show(total: number, delay?: number): IProgressRunner; - show(infiniteOrTotal: true | number, delay?: number): IProgressRunner { - if (typeof infiniteOrTotal === 'boolean') { - this.progressbar.infinite().show(delay); - } else { - this.progressbar.total(infiniteOrTotal).show(delay); - } - - return { - total: (total: number) => { - this.progressbar.total(total); - }, - - worked: (worked: number) => { - if (this.progressbar.hasTotal()) { - this.progressbar.worked(worked); - } else { - this.progressbar.infinite().show(); - } - }, - - done: () => { - this.progressbar.stop().hide(); - } - }; - } - - async showWhile(promise: Promise, delay?: number): Promise { - try { - this.progressbar.infinite().show(delay); - - await promise; - } catch (error) { - // ignore - } finally { - this.progressbar.stop().hide(); - } - } -} diff --git a/src/vs/workbench/services/progress/browser/progressService.ts b/src/vs/workbench/services/progress/browser/progressService.ts index 852faf28a934417bf8a8e266651176e52f331982..d7bb38745a10ea92d9bf11099ed04885535b58e6 100644 --- a/src/vs/workbench/services/progress/browser/progressService.ts +++ b/src/vs/workbench/services/progress/browser/progressService.ts @@ -7,7 +7,7 @@ import 'vs/css!./media/progressService'; import { localize } from 'vs/nls'; import { IDisposable, dispose, DisposableStore, MutableDisposable, Disposable } from 'vs/base/common/lifecycle'; -import { IProgressService, IProgressOptions, IProgressStep, ProgressLocation, IProgress, Progress, IProgressCompositeOptions, IProgressNotificationOptions, IProgressRunner, ILocalProgressService } from 'vs/platform/progress/common/progress'; +import { IProgressService, IProgressOptions, IProgressStep, ProgressLocation, IProgress, Progress, IProgressCompositeOptions, IProgressNotificationOptions, IProgressRunner, IProgressIndicator } from 'vs/platform/progress/common/progress'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { StatusbarAlignment, IStatusbarService } from 'vs/platform/statusbar/common/statusbar'; import { timeout } from 'vs/base/common/async'; @@ -286,7 +286,7 @@ export class ProgressService extends Disposable implements IProgressService { return this.withCompositeProgress(this.panelService.getProgressIndicator(panelid), task, options); } - private withCompositeProgress

, R = unknown>(compositeProgressService: ILocalProgressService | null, task: (progress: IProgress) => P, options: IProgressCompositeOptions): P { + private withCompositeProgress

, R = unknown>(progressIndicator: IProgressIndicator | null, task: (progress: IProgress) => P, options: IProgressCompositeOptions): P { let progressRunner: IProgressRunner | undefined = undefined; const promise = task({ @@ -305,12 +305,12 @@ export class ProgressService extends Disposable implements IProgressService { } }); - if (compositeProgressService) { + if (progressIndicator) { if (typeof options.total === 'number') { - progressRunner = compositeProgressService.show(options.total, options.delay); + progressRunner = progressIndicator.show(options.total, options.delay); promise.catch(() => undefined /* ignore */).finally(() => progressRunner ? progressRunner.done() : undefined); } else { - compositeProgressService.showWhile(promise, options.delay); + progressIndicator.showWhile(promise, options.delay); } } diff --git a/src/vs/workbench/services/progress/test/localProgressService.test.ts b/src/vs/workbench/services/progress/test/progressIndicator.test.ts similarity index 66% rename from src/vs/workbench/services/progress/test/localProgressService.test.ts rename to src/vs/workbench/services/progress/test/progressIndicator.test.ts index dad585ef4f03df032772023edbd97ac5a056b0cb..a8d2b740d0b2876e85a037472d5f8a324bdb46fa 100644 --- a/src/vs/workbench/services/progress/test/localProgressService.test.ts +++ b/src/vs/workbench/services/progress/test/progressIndicator.test.ts @@ -6,7 +6,7 @@ import * as assert from 'assert'; import { IAction, IActionViewItem } from 'vs/base/common/actions'; import { IEditorControl } from 'vs/workbench/common/editor'; -import { ScopedProgressService, ScopedService } from 'vs/workbench/services/progress/browser/localProgressService'; +import { CompositeScope, CompositeProgressIndicator } from 'vs/workbench/services/progress/browser/progressIndicator'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { IViewlet } from 'vs/workbench/common/viewlet'; @@ -16,106 +16,55 @@ class TestViewlet implements IViewlet { constructor(private id: string) { } - getId(): string { - return this.id; - } - - /** - * Returns the name of this composite to show in the title area. - */ - getTitle(): string { - return this.id; - } - - /** - * Returns the primary actions of the composite. - */ - getActions(): IAction[] { - return []; - } - - /** - * Returns the secondary actions of the composite. - */ - getSecondaryActions(): IAction[] { - return []; - } - - /** - * Returns an array of actions to show in the context menu of the composite - */ - public getContextMenuActions(): IAction[] { - return []; - } - - /** - * Returns the action item for a specific action. - */ - getActionViewItem(action: IAction): IActionViewItem { - return null!; - } - - /** - * Returns the underlying control of this composite. - */ - getControl(): IEditorControl { - return null!; - } - - /** - * Asks the underlying control to focus. - */ - focus(): void { - } - - getOptimalWidth(): number { - return 10; - } + getId(): string { return this.id; } + getTitle(): string { return this.id; } + getActions(): IAction[] { return []; } + getSecondaryActions(): IAction[] { return []; } + getContextMenuActions(): IAction[] { return []; } + getActionViewItem(action: IAction): IActionViewItem { return null!; } + getControl(): IEditorControl { return null!; } + focus(): void { } + getOptimalWidth(): number { return 10; } } -class TestScopedService extends ScopedService { - public isActive: boolean; +class TestCompositeScope extends CompositeScope { + isActive: boolean; constructor(viewletService: IViewletService, panelService: IPanelService, scopeId: string) { super(viewletService, panelService, scopeId); } - public onScopeActivated() { - this.isActive = true; - } - public onScopeDeactivated() { - this.isActive = false; - } + onScopeActivated() { this.isActive = true; } + onScopeDeactivated() { this.isActive = false; } } class TestProgressBar { - public fTotal: number; - public fWorked: number; - public fInfinite: boolean; - public fDone: boolean; + fTotal: number; + fWorked: number; + fInfinite: boolean; + fDone: boolean; - constructor() { - } + constructor() { } - public infinite() { + infinite() { this.fDone = null!; this.fInfinite = true; return this; } - public total(total: number) { + total(total: number) { this.fDone = null!; this.fTotal = total; return this; } - public hasTotal() { + hasTotal() { return !!this.fTotal; } - public worked(worked: number) { + worked(worked: number) { this.fDone = null!; if (this.fWorked) { @@ -127,7 +76,7 @@ class TestProgressBar { return this; } - public done() { + done() { this.fDone = true; this.fInfinite = null!; @@ -137,25 +86,21 @@ class TestProgressBar { return this; } - public stop() { + stop() { return this.done(); } - public show(): void { - - } - - public hide(): void { + show(): void { } - } + hide(): void { } } -suite('Progress Service', () => { +suite('Progress Indicator', () => { - test('ScopedService', () => { + test('CompositeScope', () => { let viewletService = new TestViewletService(); let panelService = new TestPanelService(); - let service = new TestScopedService(viewletService, panelService, 'test.scopeId'); + let service = new TestCompositeScope(viewletService, panelService, 'test.scopeId'); const testViewlet = new TestViewlet('test.scopeId'); assert(!service.isActive); @@ -167,11 +112,11 @@ suite('Progress Service', () => { }); - test('WorkbenchProgressService', async () => { + test('CompositeProgressIndicator', async () => { let testProgressBar = new TestProgressBar(); let viewletService = new TestViewletService(); let panelService = new TestPanelService(); - let service = new ScopedProgressService((testProgressBar), 'test.scopeId', true, viewletService, panelService); + let service = new CompositeProgressIndicator((testProgressBar), 'test.scopeId', true, viewletService, panelService); // Active: Show (Infinite) let fn = service.show(true); diff --git a/src/vs/workbench/services/viewlet/browser/viewlet.ts b/src/vs/workbench/services/viewlet/browser/viewlet.ts index a20befa69402fc6ff3e00293f81a6c19eff0fee1..92349b87a4b56583436bf65d9e806ab78ec0f96f 100644 --- a/src/vs/workbench/services/viewlet/browser/viewlet.ts +++ b/src/vs/workbench/services/viewlet/browser/viewlet.ts @@ -7,7 +7,7 @@ import { IViewlet } from 'vs/workbench/common/viewlet'; import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation'; import { Event } from 'vs/base/common/event'; import { ViewletDescriptor } from 'vs/workbench/browser/viewlet'; -import { ILocalProgressService } from 'vs/platform/progress/common/progress'; +import { IProgressIndicator } from 'vs/platform/progress/common/progress'; export const IViewletService = createDecorator('viewletService'); @@ -48,7 +48,7 @@ export interface IViewletService { /** * Returns the progress indicator for the side bar. */ - getProgressIndicator(id: string): ILocalProgressService | null; + getProgressIndicator(id: string): IProgressIndicator | null; /** * Hide the active viewlet.