diff --git a/src/vs/base/common/async.ts b/src/vs/base/common/async.ts index deb94190661ddd73dbcf086247938e1f8fe97e99..c1c84d77bd89870e499c5ba629a8080c866d4c58 100644 --- a/src/vs/base/common/async.ts +++ b/src/vs/base/common/async.ts @@ -748,45 +748,3 @@ export function ninvoke(thisArg: any, fn: Function, ...args: any[]): TPromise export function ninvoke(thisArg: any, fn: Function, ...args: any[]): any { return new TPromise((c, e) => fn.call(thisArg, ...args, (err: any, result: any) => err ? e(err) : c(result)), () => null); } - -/** - * An emitter that will ignore any events that occur during a specific code - * execution triggered via throttle() until the promise has finished (either - * successfully or with an error). Only after the promise has finished, the - * last event that was fired during the operation will get emitted. - * - */ -export class ThrottledEmitter extends Emitter { - private suspended: boolean; - - private lastEvent: T; - private hasLastEvent: boolean; - - public throttle(promise: TPromise): TPromise { - this.suspended = true; - - return always(promise, () => this.resume()); - } - - public fire(event?: T): any { - if (this.suspended) { - this.lastEvent = event; - this.hasLastEvent = true; - - return; - } - - return super.fire(event); - } - - private resume(): void { - this.suspended = false; - - if (this.hasLastEvent) { - this.fire(this.lastEvent); - } - - this.hasLastEvent = false; - this.lastEvent = void 0; - } -} diff --git a/src/vs/base/test/common/async.test.ts b/src/vs/base/test/common/async.test.ts index 58dfab4737e86b22501d0d60cbc2cd03b01d2028..d1ef408cb3f7ab1576d01e387d3d2bc8c9135cdb 100644 --- a/src/vs/base/test/common/async.test.ts +++ b/src/vs/base/test/common/async.test.ts @@ -603,29 +603,4 @@ suite('Async', () => { const r1Queue2 = queue.queueFor(URI.file('/some/path')); assert.notEqual(r1Queue, r1Queue2); // previous one got disposed after finishing }); - - test('ThrottledEmitter', function () { - const emitter = new Async.ThrottledEmitter(); - - const fnThatEmitsEvent = () => { - emitter.fire(); - }; - - const promiseFn = TPromise.timeout(0).then(() => { - fnThatEmitsEvent(); - fnThatEmitsEvent(); - fnThatEmitsEvent(); - }); - - let count = 0; - emitter.event(() => { - count++; - }); - - emitter.throttle(promiseFn); - - promiseFn.then(() => { - assert.equal(count, 1); - }); - }); }); diff --git a/src/vs/workbench/browser/parts/editor/editorCommands.ts b/src/vs/workbench/browser/parts/editor/editorCommands.ts index 2a5751c9f08a929c5d4bec4565de974f98a61b8f..054323ce56c4b08f7bf7e82ba48ae519286a639e 100644 --- a/src/vs/workbench/browser/parts/editor/editorCommands.ts +++ b/src/vs/workbench/browser/parts/editor/editorCommands.ts @@ -11,7 +11,6 @@ import { TextCompareEditorVisibleContext, EditorInput, IEditorIdentifier, IEdito import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { TextDiffEditor } from 'vs/workbench/browser/parts/editor/textDiffEditor'; -import { EditorGroup } from 'vs/workbench/common/editor/editorGroup'; import { KeyMod, KeyCode, KeyChord } from 'vs/base/common/keyCodes'; import { TPromise } from 'vs/base/common/winjs.base'; import URI from 'vs/base/common/uri'; @@ -540,21 +539,28 @@ function resolveCommandsContext(editorGroupService: INextEditorGroupsService, co } export function getMultiSelectedEditorContexts(editorContext: IEditorCommandsContext, listService: IListService, editorGroupService: INextEditorGroupsService): IEditorCommandsContext[] { + // First check for a focused list to return the selected items from const list = listService.lastFocusedList; if (list instanceof List && list.isDOMFocused()) { - const elementToContext = (element: IEditorIdentifier | EditorGroup) => - element instanceof EditorGroup ? { groupId: element.id, editorIndex: undefined } : { groupId: element.groupId, editorIndex: editorGroupService.getGroup(element.groupId).getIndexOfEditor(element.editor) }; - const onlyEditorGroupAndEditor = (e: IEditorIdentifier | EditorGroup) => e instanceof EditorGroup || ('editor' in e && 'group' in e); + const elementToContext = (element: IEditorIdentifier | IEditorGroup) => { + if (isEditorGroup(element)) { + return { groupId: element.id, editorIndex: void 0 }; + } + + return { groupId: element.groupId, editorIndex: editorGroupService.getGroup(element.groupId).getIndexOfEditor(element.editor) }; + }; - const focusedElements: (IEditorIdentifier | EditorGroup)[] = list.getFocusedElements().filter(onlyEditorGroupAndEditor); - // need to take into account when editor context is { group: group } - const focus = editorContext ? editorContext : focusedElements.length ? focusedElements.map(elementToContext)[0] : undefined; + const onlyEditorGroupAndEditor = (e: IEditorIdentifier | IEditorGroup) => isEditorGroup(e) || isEditorIdentifier(e); + + const focusedElements: (IEditorIdentifier | IEditorGroup)[] = list.getFocusedElements().filter(onlyEditorGroupAndEditor); + const focus = editorContext ? editorContext : focusedElements.length ? focusedElements.map(elementToContext)[0] : void 0; // need to take into account when editor context is { group: group } if (focus) { - const selection: (IEditorIdentifier | EditorGroup)[] = list.getSelectedElements().filter(onlyEditorGroupAndEditor); + const selection: (IEditorIdentifier | IEditorGroup)[] = list.getSelectedElements().filter(onlyEditorGroupAndEditor); + // Only respect selection if it contains focused element - if (selection && selection.some(s => s instanceof EditorGroup ? s.id === focus.groupId : s.groupId === focus.groupId && editorGroupService.getGroup(s.groupId).getIndexOfEditor(s.editor) === focus.editorIndex)) { + if (selection && selection.some(s => isEditorGroup(s) ? s.id === focus.groupId : s.groupId === focus.groupId && editorGroupService.getGroup(s.groupId).getIndexOfEditor(s.editor) === focus.editorIndex)) { return selection.map(elementToContext); } @@ -566,6 +572,18 @@ export function getMultiSelectedEditorContexts(editorContext: IEditorCommandsCon return !!editorContext ? [editorContext] : []; } +function isEditorGroup(thing: any): thing is IEditorGroup { + const group = thing as IEditorGroup; + + return group && typeof group.id === 'number' && Array.isArray(group.editors); +} + +function isEditorIdentifier(thing: any): thing is IEditorIdentifier { + const identifier = thing as IEditorIdentifier; + + return identifier && typeof identifier.groupId === 'number'; +} + export function setup(): void { registerActiveEditorMoveCommand(); registerDiffEditorCommands(); diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts index 2e731d00e8f0575add96f60ab8cfc43ab0be0e3d..1e0d71ad99d923c5a2961821bd68b83962201e73 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -11,7 +11,7 @@ import * as types from 'vs/base/common/types'; import URI from 'vs/base/common/uri'; import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle'; import { IEditor as ICodeEditor, IEditorViewState, ScrollType, IDiffEditor } from 'vs/editor/common/editorCommon'; -import { IEditorModel, IEditorOptions, ITextEditorOptions, IBaseResourceInput, Position } from 'vs/platform/editor/common/editor'; +import { IEditorModel, IEditorOptions, ITextEditorOptions, IBaseResourceInput } from 'vs/platform/editor/common/editor'; import { IInstantiationService, IConstructorSignature0 } from 'vs/platform/instantiation/common/instantiation'; import { RawContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { Registry } from 'vs/platform/registry/common/platform'; @@ -1176,57 +1176,3 @@ export const Extensions = { }; Registry.add(Extensions.EditorInputFactories, new EditorInputFactoryRegistry()); - -//#region TODO@grid obsolete - -export interface IStacksModelChangeEvent { - group: ILegacyEditorGroup; - editor?: IEditorInput; - structural?: boolean; -} - -export interface IEditorStacksModel { - - onModelChanged: Event; - - onWillCloseEditor: Event; - onEditorClosed: Event; - - groups: ILegacyEditorGroup[]; - activeGroup: ILegacyEditorGroup; - isActive(group: ILegacyEditorGroup): boolean; - - getGroup(id: GroupIdentifier): ILegacyEditorGroup; - - positionOfGroup(group: ILegacyEditorGroup): Position; - groupAt(position: Position): ILegacyEditorGroup; - - next(jumpGroups: boolean, cycleAtEnd?: boolean): IEditorIdentifier; - previous(jumpGroups: boolean, cycleAtStart?: boolean): IEditorIdentifier; - last(): IEditorIdentifier; - - isOpen(resource: URI): boolean; - - toString(): string; -} - -export interface ILegacyEditorGroup { - id: GroupIdentifier; - count: number; - activeEditor: IEditorInput; - previewEditor: IEditorInput; - - getEditor(index: number): IEditorInput; - getEditor(resource: URI): IEditorInput; - indexOf(editor: IEditorInput): number; - - contains(editorOrResource: IEditorInput | URI): boolean; - - getEditors(mru?: boolean): IEditorInput[]; - isActive(editor: IEditorInput): boolean; - isPreview(editor: IEditorInput): boolean; - isPinned(index: number): boolean; - isPinned(editor: IEditorInput): boolean; -} - -//#endregion diff --git a/src/vs/workbench/common/editor/editorGroup.ts b/src/vs/workbench/common/editor/editorGroup.ts index 239ecd2f2e10f36d5d5d3439a64733ca90d179ce..ed1162c922e723156c1ba5be5ebb7daff4362954 100644 --- a/src/vs/workbench/common/editor/editorGroup.ts +++ b/src/vs/workbench/common/editor/editorGroup.ts @@ -6,7 +6,7 @@ 'use strict'; import { Event, Emitter, once } from 'vs/base/common/event'; -import { Extensions, IEditorInputFactoryRegistry, EditorInput, toResource, ILegacyEditorGroup, IEditorIdentifier, IEditorCloseEvent, GroupIdentifier, SideBySideEditorInput, CloseDirection } from 'vs/workbench/common/editor'; +import { Extensions, IEditorInputFactoryRegistry, EditorInput, toResource, IEditorIdentifier, IEditorCloseEvent, GroupIdentifier, SideBySideEditorInput, CloseDirection } from 'vs/workbench/common/editor'; import URI from 'vs/base/common/uri'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration'; @@ -54,7 +54,7 @@ export function isSerializedEditorGroup(obj?: any): obj is ISerializedEditorGrou return obj && typeof obj === 'object' && Array.isArray(group.editors) && Array.isArray(group.mru); } -export class EditorGroup extends Disposable implements ILegacyEditorGroup { +export class EditorGroup extends Disposable { private static IDS = 0; diff --git a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts index a3d94805d650a842df6634b5e914438ded47c34e..57ba15ae14cdcf486f259e92315fa882c93840bf 100644 --- a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts +++ b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts @@ -12,19 +12,19 @@ import { ICommandService } from 'vs/platform/commands/common/commands'; import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; import { ConfigurationResolverService } from 'vs/workbench/services/configurationResolver/electron-browser/configurationResolverService'; import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; -import { TestEnvironmentService, TestNextEditorService, TestContextService } from 'vs/workbench/test/workbenchTestServices'; +import { TestEnvironmentService, TestEditorService, TestContextService } from 'vs/workbench/test/workbenchTestServices'; import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; suite('Configuration Resolver Service', () => { let configurationResolverService: IConfigurationResolverService; let envVariables: { [key: string]: string } = { key1: 'Value for key1', key2: 'Value for key2' }; let mockCommandService: MockCommandService; - let editorService: TestNextEditorService; + let editorService: TestEditorService; let workspace: IWorkspaceFolder; setup(() => { mockCommandService = new MockCommandService(); - editorService = new TestNextEditorService(); + editorService = new TestEditorService(); workspace = { uri: uri.parse('file:///VSCode/workspaceLocation'), name: 'hey', @@ -116,7 +116,7 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestNextEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService()); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService()); assert.strictEqual(service.resolve(workspace, 'abc ${config:editor.fontFamily} xyz'), 'abc foo xyz'); }); @@ -133,7 +133,7 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestNextEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService()); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService()); assert.strictEqual(service.resolve(workspace, 'abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo bar xyz'); }); @@ -150,7 +150,7 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestNextEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService()); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService()); if (platform.isWindows) { assert.strictEqual(service.resolve(workspace, 'abc ${config:editor.fontFamily} ${workspaceFolder} ${env:key1} xyz'), 'abc foo \\VSCode\\workspaceLocation Value for key1 xyz'); } else { @@ -171,7 +171,7 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestNextEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService()); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService()); if (platform.isWindows) { assert.strictEqual(service.resolve(workspace, '${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} ${workspaceFolder} - ${workspaceFolder} ${env:key1} - ${env:key2}'), 'foo bar \\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for key1 - Value for key2'); } else { @@ -205,7 +205,7 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestNextEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService()); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService()); assert.strictEqual(service.resolve(workspace, 'abc ${config:editor.fontFamily} ${config:editor.lineNumbers} ${config:editor.insertSpaces} xyz'), 'abc foo 123 false xyz'); }); @@ -215,7 +215,7 @@ suite('Configuration Resolver Service', () => { editor: {} }); - let service = new ConfigurationResolverService(envVariables, new TestNextEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService()); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService()); assert.strictEqual(service.resolve(workspace, 'abc ${unknownVariable} xyz'), 'abc ${unknownVariable} xyz'); assert.strictEqual(service.resolve(workspace, 'abc ${env:unknownVariable} xyz'), 'abc xyz'); }); @@ -228,7 +228,7 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestNextEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService()); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService()); assert.throws(() => service.resolve(workspace, 'abc ${env} xyz')); assert.throws(() => service.resolve(workspace, 'abc ${env:} xyz')); diff --git a/src/vs/workbench/services/editor/common/editorService.ts b/src/vs/workbench/services/editor/common/editorService.ts index 5b68ffdb96a4e6abb0358b69ebc8099aec099560..ae6757ae730bca5b0609db17adda0373d35d4b8e 100644 --- a/src/vs/workbench/services/editor/common/editorService.ts +++ b/src/vs/workbench/services/editor/common/editorService.ts @@ -11,7 +11,7 @@ import { IEditorOptions, ITextEditorOptions, Position, IResourceInput } from 'vs import URI from 'vs/base/common/uri'; import { Registry } from 'vs/platform/registry/common/platform'; import { basename } from 'vs/base/common/paths'; -import { EditorInput, EditorOptions, TextEditorOptions, Extensions as EditorExtensions, IResourceDiffInput, IResourceSideBySideInput, IUntitledResourceInput, SideBySideEditorInput, IFileEditorInput, IFileInputFactory, IEditorInputFactoryRegistry, IEditorStacksModel, IEditorOpeningEvent, ILegacyEditorGroup, IStacksModelChangeEvent, IEditorCloseEvent, IEditorIdentifier, CloseDirection, IEditor, IEditorInput } from 'vs/workbench/common/editor'; +import { EditorInput, EditorOptions, TextEditorOptions, Extensions as EditorExtensions, IResourceDiffInput, IResourceSideBySideInput, IUntitledResourceInput, SideBySideEditorInput, IFileEditorInput, IFileInputFactory, IEditorInputFactoryRegistry, IEditorOpeningEvent, IEditorCloseEvent, IEditorIdentifier, CloseDirection, IEditor, IEditorInput } from 'vs/workbench/common/editor'; import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput'; import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; @@ -142,7 +142,7 @@ export interface IEditorPart { export class NoOpEditorPart implements IEditorPart, IEditorGroupService { _serviceBrand: ServiceIdentifier; - stacks: IEditorStacksModel; + stacks: any; constructor(private instantiationService: IInstantiationService) { this.stacks = new NoOpEditorStacksModel(); @@ -175,7 +175,7 @@ export class NoOpEditorPart implements IEditorPart, IEditorGroupService { moveEditor(...args: any[]) { } - getStacksModel(): IEditorStacksModel { + getStacksModel(): any { return this.stacks; } @@ -230,28 +230,28 @@ export class NoOpEditorPart implements IEditorPart, IEditorGroupService { } } -export class NoOpEditorStacksModel implements IEditorStacksModel { +export class NoOpEditorStacksModel { - onModelChanged: Event = new Emitter().event; + onModelChanged: Event = new Emitter().event; onWillCloseEditor: Event = new Emitter().event; onEditorClosed: Event = new Emitter().event; - groups: ILegacyEditorGroup[] = []; - activeGroup: ILegacyEditorGroup; + groups: any[] = []; + activeGroup: any; - isActive(group: ILegacyEditorGroup): boolean { + isActive(group: any): boolean { return false; } - getGroup(id: number): ILegacyEditorGroup { + getGroup(id: number): any { return null; } - positionOfGroup(group: ILegacyEditorGroup): Position { + positionOfGroup(group: any): Position { return Position.ONE; } - groupAt(position: Position): ILegacyEditorGroup { + groupAt(position: Position): any { return null; } diff --git a/src/vs/workbench/services/group/common/groupService.ts b/src/vs/workbench/services/group/common/groupService.ts index f28b47cf51091d8af9fc9f71b5711ac114ad715c..eb3abce439813df2dc1deefb1b282cffb8c57545 100644 --- a/src/vs/workbench/services/group/common/groupService.ts +++ b/src/vs/workbench/services/group/common/groupService.ts @@ -7,7 +7,7 @@ import { createDecorator, ServiceIdentifier, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { Position } from 'vs/platform/editor/common/editor'; -import { IEditorStacksModel, ILegacyEditorGroup, IEditorOpeningEvent, IEditorInput } from 'vs/workbench/common/editor'; +import { IEditorOpeningEvent, IEditorInput } from 'vs/workbench/common/editor'; import { Event } from 'vs/base/common/event'; export enum GroupArrangement { @@ -75,19 +75,19 @@ export interface IEditorGroupService { /** * Keyboard focus the editor group at the provided position. */ - focusGroup(group: ILegacyEditorGroup): void; + focusGroup(group: any): void; focusGroup(position: Position): void; /** * Activate the editor group at the provided position without moving focus. */ - activateGroup(group: ILegacyEditorGroup): void; + activateGroup(group: any): void; activateGroup(position: Position): void; /** * Allows to move the editor group from one position to another. */ - moveGroup(from: ILegacyEditorGroup, to: ILegacyEditorGroup): void; + moveGroup(from: any, to: any): void; moveGroup(from: Position, to: Position): void; /** @@ -114,20 +114,20 @@ export interface IEditorGroupService { /** * Adds the pinned state to an editor, removing it from being a preview editor. */ - pinEditor(group: ILegacyEditorGroup, input: IEditorInput): void; + pinEditor(group: any, input: IEditorInput): void; pinEditor(position: Position, input: IEditorInput): void; /** * Moves an editor from one group to another. The index in the group is optional. * The inactive option is applied when moving across groups. */ - moveEditor(input: IEditorInput, from: ILegacyEditorGroup, to: ILegacyEditorGroup, moveOptions?: IMoveOptions): void; + moveEditor(input: IEditorInput, from: any, to: any, moveOptions?: IMoveOptions): void; moveEditor(input: IEditorInput, from: Position, to: Position, moveOptions?: IMoveOptions): void; /** * Provides access to the editor stacks model */ - getStacksModel(): IEditorStacksModel; + getStacksModel(): any; /** * Returns tab options. diff --git a/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts b/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts index 4348088592ad07b0cde21beca3b9d22f0c197b1f..59d4f4f5da98b42399ed97b8729fdcbc88df3382 100644 --- a/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts +++ b/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts @@ -16,7 +16,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { KeyCode, SimpleKeybinding, ChordKeybinding } from 'vs/base/common/keyCodes'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import * as extfs from 'vs/base/node/extfs'; -import { TestTextFileService, TestLifecycleService, TestBackupFileService, TestContextService, TestTextResourceConfigurationService, TestHashService, TestEnvironmentService, TestStorageService, TestNextEditorGroupsService, TestNextEditorService } from 'vs/workbench/test/workbenchTestServices'; +import { TestTextFileService, TestLifecycleService, TestBackupFileService, TestContextService, TestTextResourceConfigurationService, TestHashService, TestEnvironmentService, TestStorageService, TestEditorGroupsService, TestEditorService } from 'vs/workbench/test/workbenchTestServices'; import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService'; import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService'; import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService'; @@ -78,8 +78,8 @@ suite('Keybindings Editing', () => { instantiationService.stub(ILifecycleService, lifecycleService); instantiationService.stub(IContextKeyService, instantiationService.createInstance(MockContextKeyService)); instantiationService.stub(IHashService, new TestHashService()); - instantiationService.stub(INextEditorGroupsService, new TestNextEditorGroupsService()); - instantiationService.stub(INextEditorService, new TestNextEditorService()); + instantiationService.stub(INextEditorGroupsService, new TestEditorGroupsService()); + instantiationService.stub(INextEditorService, new TestEditorService()); instantiationService.stub(ITelemetryService, NullTelemetryService); instantiationService.stub(IModeService, ModeServiceImpl); instantiationService.stub(IModelService, instantiationService.createInstance(ModelServiceImpl)); diff --git a/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts b/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts index 4dbf3ed6937815c058c93e6552f61a679029a908..2f2a863607d964559fa9776fa72d1d021b78f4c0 100644 --- a/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts +++ b/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts @@ -14,7 +14,7 @@ import * as Platform from 'vs/platform/registry/common/platform'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils'; -import { workbenchInstantiationService, TestNextEditorGroup } from 'vs/workbench/test/workbenchTestServices'; +import { workbenchInstantiationService, TestEditorGroup } from 'vs/workbench/test/workbenchTestServices'; import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput'; import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService'; import URI from 'vs/base/common/uri'; @@ -99,7 +99,7 @@ suite('Workbench base editor', () => { assert.strictEqual(input, e.input); assert.strictEqual(options, e.options); - const group = new TestNextEditorGroup(1); + const group = new TestEditorGroup(1); e.setVisible(true, group); assert(e.isVisible()); assert.equal(e.group, group); diff --git a/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts b/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts index f5d798a723aa480ec557ad3c71624106b307235d..556d41a1061ee117b5d0fcdd0d62a3b6f298a9eb 100644 --- a/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts +++ b/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts @@ -6,7 +6,7 @@ import * as assert from 'assert'; import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock'; import URI from 'vs/base/common/uri'; -import { workbenchInstantiationService, TestNextEditorService } from 'vs/workbench/test/workbenchTestServices'; +import { workbenchInstantiationService, TestEditorService } from 'vs/workbench/test/workbenchTestServices'; import { IModelService } from 'vs/editor/common/services/modelService'; import { IModeService } from 'vs/editor/common/services/modeService'; import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl'; @@ -33,7 +33,7 @@ suite('Editor - Range decorations', () => { setup(() => { instantiationService = workbenchInstantiationService(); - instantiationService.stub(INextEditorService, new TestNextEditorService()); + instantiationService.stub(INextEditorService, new TestEditorService()); instantiationService.stub(IModeService, ModeServiceImpl); instantiationService.stub(IModelService, stubModelService(instantiationService)); text = 'LINE1' + '\n' + 'LINE2' + '\n' + 'LINE3' + '\n' + 'LINE4' + '\r\n' + 'LINE5'; diff --git a/src/vs/workbench/test/common/editor/editor.test.ts b/src/vs/workbench/test/common/editor/editor.test.ts index f4c7b98afa44a99631ad819a223f1648dcf9f297..100111ea2d2a59da94b6b0990646954acb46d550 100644 --- a/src/vs/workbench/test/common/editor/editor.test.ts +++ b/src/vs/workbench/test/common/editor/editor.test.ts @@ -13,7 +13,7 @@ import { IEditorModel } from 'vs/platform/editor/common/editor'; import URI from 'vs/base/common/uri'; import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { workbenchInstantiationService, TestNextEditorGroupsService, TestNextEditorGroup } from 'vs/workbench/test/workbenchTestServices'; +import { workbenchInstantiationService, TestEditorGroupsService, TestEditorGroup } from 'vs/workbench/test/workbenchTestServices'; import { Schemas } from 'vs/base/common/network'; class ServiceAccessor { @@ -88,14 +88,14 @@ suite('Workbench editor', () => { }); test('EditorViewStateMemento - basics', function () { - const testGroup0 = new TestNextEditorGroup(0); - const testGroup1 = new TestNextEditorGroup(1); - const testGroup4 = new TestNextEditorGroup(4); + const testGroup0 = new TestEditorGroup(0); + const testGroup1 = new TestEditorGroup(1); + const testGroup4 = new TestEditorGroup(4); - const groupService = new TestNextEditorGroupsService([ + const groupService = new TestEditorGroupsService([ testGroup0, testGroup1, - new TestNextEditorGroup(2) + new TestEditorGroup(2) ]); interface TestViewState { @@ -156,7 +156,7 @@ suite('Workbench editor', () => { }); test('EditorViewStateMemento - use with editor input', function () { - const testGroup0 = new TestNextEditorGroup(0); + const testGroup0 = new TestEditorGroup(0); interface TestViewState { line: number; @@ -179,7 +179,7 @@ suite('Workbench editor', () => { } const rawMemento = Object.create(null); - let memento = new EditorViewStateMemento(new TestNextEditorGroupsService(), rawMemento, 'key', 3); + let memento = new EditorViewStateMemento(new TestEditorGroupsService(), rawMemento, 'key', 3); const testInputA = new TestEditorInput(URI.file('/A')); diff --git a/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts b/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts index 63405d2e2d0420ceb0fd2fd7e558690160ba5327..2d71fde6f1cfea6756a1fcbffbf1be011129e13f 100644 --- a/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts +++ b/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts @@ -23,7 +23,7 @@ import { Range } from 'vs/editor/common/core/range'; import { Position } from 'vs/editor/common/core/position'; import { IModelService } from 'vs/editor/common/services/modelService'; import { EditOperation } from 'vs/editor/common/core/editOperation'; -import { TestFileService, TestNextEditorService } from 'vs/workbench/test/workbenchTestServices'; +import { TestFileService, TestEditorService } from 'vs/workbench/test/workbenchTestServices'; import { TPromise } from 'vs/base/common/winjs.base'; import { IFileStat } from 'vs/platform/files/common/files'; import { ResourceTextEdit } from 'vs/editor/common/modes'; @@ -81,7 +81,7 @@ suite('MainThreadEditors', () => { onEditorGroupMoved = Event.None; }; - const bulkEditService = new BulkEditService(modelService, new TestNextEditorService(), null, fileService); + const bulkEditService = new BulkEditService(modelService, new TestEditorService(), null, fileService); const rpcProtocol = new TestRPCProtocol(); rpcProtocol.set(ExtHostContext.ExtHostDocuments, new class extends mock() { diff --git a/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts b/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts index a9a7e0630e78d9c466b277eab224db73baa47567..a24815a02bad49d1325bc67c3661f8221e8e9710 100644 --- a/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts +++ b/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts @@ -21,7 +21,7 @@ import { IQuickOpenRegistry, Extensions } from 'vs/workbench/browser/quickopen'; import { Registry } from 'vs/platform/registry/common/platform'; import { SearchService } from 'vs/workbench/services/search/node/searchService'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; -import { TestEnvironmentService, TestContextService, TestNextEditorService, TestNextEditorGroupsService } from 'vs/workbench/test/workbenchTestServices'; +import { TestEnvironmentService, TestContextService, TestEditorService, TestEditorGroupsService } from 'vs/workbench/test/workbenchTestServices'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { TPromise } from 'vs/base/common/winjs.base'; import URI from 'vs/base/common/uri'; @@ -76,8 +76,8 @@ suite.skip('QuickOpen performance (integration)', () => { [IConfigurationService, configurationService], [IModelService, new ModelServiceImpl(null, configurationService)], [IWorkspaceContextService, new TestContextService(testWorkspace(URI.file(testWorkspacePath)))], - [INextEditorService, new TestNextEditorService()], - [INextEditorGroupsService, new TestNextEditorGroupsService()], + [INextEditorService, new TestEditorService()], + [INextEditorGroupsService, new TestEditorGroupsService()], [IEnvironmentService, TestEnvironmentService], [IUntitledEditorService, createSyncDescriptor(UntitledEditorService)], [ISearchService, createSyncDescriptor(SearchService)] diff --git a/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts b/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts index 9cfe397451cac7a4c78a3be63804e56dfba608a7..7d8d39bc310b033436b7ab8f73e2d3e4d07062f7 100644 --- a/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts +++ b/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts @@ -19,7 +19,7 @@ import * as minimist from 'minimist'; import * as path from 'path'; import { SearchService } from 'vs/workbench/services/search/node/searchService'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; -import { TestEnvironmentService, TestContextService, TestNextEditorService, TestNextEditorGroupsService } from 'vs/workbench/test/workbenchTestServices'; +import { TestEnvironmentService, TestContextService, TestEditorService, TestEditorGroupsService } from 'vs/workbench/test/workbenchTestServices'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { TPromise } from 'vs/base/common/winjs.base'; import URI from 'vs/base/common/uri'; @@ -64,8 +64,8 @@ suite.skip('TextSearch performance (integration)', () => { [IConfigurationService, configurationService], [IModelService, new ModelServiceImpl(null, configurationService)], [IWorkspaceContextService, new TestContextService(testWorkspace(URI.file(testWorkspacePath)))], - [INextEditorService, new TestNextEditorService()], - [INextEditorGroupsService, new TestNextEditorGroupsService()], + [INextEditorService, new TestEditorService()], + [INextEditorGroupsService, new TestEditorGroupsService()], [IEnvironmentService, TestEnvironmentService], [IUntitledEditorService, createSyncDescriptor(UntitledEditorService)], [ISearchService, createSyncDescriptor(SearchService)], diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 5a0b6c92fff7ef884e4c89dc4a3c52b5fe1c4e6f..7087d4d3e6107cbe28e13e639532845bce0f0de9 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -14,7 +14,7 @@ import URI from 'vs/base/common/uri'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils'; import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common/storageService'; -import { ILegacyEditorGroup, ConfirmResult, IEditorOpeningEvent, IEditorInputWithOptions, CloseDirection, IEditorIdentifier, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInput, IEditor, IEditorCloseEvent } from 'vs/workbench/common/editor'; +import { ConfirmResult, IEditorOpeningEvent, IEditorInputWithOptions, CloseDirection, IEditorIdentifier, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInput, IEditor, IEditorCloseEvent } from 'vs/workbench/common/editor'; import { Event, Emitter } from 'vs/base/common/event'; import Severity from 'vs/base/common/severity'; import { IBackupFileService } from 'vs/workbench/services/backup/common/backup'; @@ -23,12 +23,11 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag import { IPartService, Parts, Position as PartPosition, IDimension } from 'vs/workbench/services/part/common/partService'; import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; -import { IEditorOptions, Position, IResourceInput } from 'vs/platform/editor/common/editor'; +import { IEditorOptions, IResourceInput } from 'vs/platform/editor/common/editor'; import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { IWorkspaceContextService, IWorkspace as IWorkbenchWorkspace, WorkbenchState, IWorkspaceFolder, IWorkspaceFoldersChangeEvent } from 'vs/platform/workspace/common/workspace'; import { ILifecycleService, ShutdownEvent, ShutdownReason, StartupKind, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; -import { IEditorGroupService, GroupArrangement, GroupOrientation, IEditorTabOptions, IMoveOptions } from 'vs/workbench/services/group/common/groupService'; import { TextFileService } from 'vs/workbench/services/textfile/common/textFileService'; import { FileOperationEvent, IFileService, IResolveContentOptions, FileOperationError, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, IContent, IUpdateContentOptions, IStreamContent, ICreateFileOptions, ITextSnapshot, IResourceEncodings } from 'vs/platform/files/common/files'; import { IModelService } from 'vs/editor/common/services/modelService'; @@ -38,7 +37,7 @@ import { IRawTextContent, ITextFileService } from 'vs/workbench/services/textfil import { parseArgs } from 'vs/platform/environment/node/argv'; import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; import { IModeService } from 'vs/editor/common/services/modeService'; -import { IWorkbenchEditorService, ICloseEditorsFilter, NoOpEditorStacksModel } from 'vs/workbench/services/editor/common/editorService'; +import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { IInstantiationService, ServicesAccessor, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation'; import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; @@ -255,9 +254,7 @@ export function workbenchInstantiationService(): IInstantiationService { instantiationService.stub(ITextResourceConfigurationService, new TestTextResourceConfigurationService(configService)); instantiationService.stub(IUntitledEditorService, instantiationService.createInstance(UntitledEditorService)); instantiationService.stub(IStorageService, new TestStorageService()); - instantiationService.stub(IWorkbenchEditorService, new TestEditorService()); instantiationService.stub(IPartService, new TestPartService()); - instantiationService.stub(IEditorGroupService, new TestEditorGroupService()); instantiationService.stub(IModeService, ModeServiceImpl); instantiationService.stub(IHistoryService, new TestHistoryService()); instantiationService.stub(IModelService, instantiationService.createInstance(ModelServiceImpl)); @@ -277,8 +274,8 @@ export function workbenchInstantiationService(): IInstantiationService { instantiationService.stub(IEnvironmentService, TestEnvironmentService); instantiationService.stub(IThemeService, new TestThemeService()); instantiationService.stub(IHashService, new TestHashService()); - instantiationService.stub(INextEditorGroupsService, new TestNextEditorGroupsService([new TestNextEditorGroup(0)])); - const editorService = new TestNextEditorService(); + instantiationService.stub(INextEditorGroupsService, new TestEditorGroupsService([new TestEditorGroup(0)])); + const editorService = new TestEditorService(); instantiationService.stub(INextEditorService, editorService); instantiationService.stub(ICodeEditorService, new TestCodeEditorService()); @@ -497,213 +494,10 @@ export class TestStorageService implements IStorageService { } } -export class TestEditorGroupService implements IEditorGroupService { - public _serviceBrand: any; - - private stacksModel; - - private readonly _onEditorsChanged: Emitter; - private readonly _onEditorOpening: Emitter; - private readonly _onEditorOpenFail: Emitter; - private readonly _onEditorsMoved: Emitter; - private readonly _onGroupOrientationChanged: Emitter; - private readonly _onTabOptionsChanged: Emitter; - - constructor(callback?: (method: string) => void) { - this._onEditorsMoved = new Emitter(); - this._onEditorsChanged = new Emitter(); - this._onEditorOpening = new Emitter(); - this._onGroupOrientationChanged = new Emitter(); - this._onEditorOpenFail = new Emitter(); - this._onTabOptionsChanged = new Emitter(); - - let services = new ServiceCollection(); - - services.set(IStorageService, new TestStorageService()); - services.set(IConfigurationService, new TestConfigurationService()); - services.set(IWorkspaceContextService, new TestContextService()); - const lifecycle = new TestLifecycleService(); - services.set(ILifecycleService, lifecycle); - services.set(ITelemetryService, NullTelemetryService); - - this.stacksModel = new NoOpEditorStacksModel(); - } - - public fireChange(): void { - this._onEditorsChanged.fire(); - } - - public get onEditorsChanged(): Event { - return this._onEditorsChanged.event; - } - - public get onEditorOpening(): Event { - return this._onEditorOpening.event; - } - - public get onEditorOpenFail(): Event { - return this._onEditorOpenFail.event; - } - - public get onEditorGroupMoved(): Event { - return this._onEditorsMoved.event; - } - - public get onGroupOrientationChanged(): Event { - return this._onGroupOrientationChanged.event; - } - - public get onTabOptionsChanged(): Event { - return this._onTabOptionsChanged.event; - } - - public focusGroup(group: ILegacyEditorGroup): void; - public focusGroup(position: Position): void; - public focusGroup(arg1: any): void { - - } - - public activateGroup(group: ILegacyEditorGroup): void; - public activateGroup(position: Position): void; - public activateGroup(arg1: any): void { - - } - - public moveGroup(from: ILegacyEditorGroup, to: ILegacyEditorGroup): void; - public moveGroup(from: Position, to: Position): void; - public moveGroup(arg1: any, arg2: any): void { - - } - - public arrangeGroups(arrangement: GroupArrangement): void { - - } - - public setGroupOrientation(orientation: GroupOrientation): void { - - } - - public getGroupOrientation(): GroupOrientation { - return 'vertical'; - } - - public resizeGroup(position: Position, groupSizeChange: number): void { - - } - - public pinEditor(group: ILegacyEditorGroup, input: IEditorInput): void; - public pinEditor(position: Position, input: IEditorInput): void; - public pinEditor(arg1: any, input: IEditorInput): void { - } - - public moveEditor(input: IEditorInput, from: ILegacyEditorGroup, to: ILegacyEditorGroup, moveOptions?: IMoveOptions): void; - public moveEditor(input: IEditorInput, from: Position, to: Position, moveOptions?: IMoveOptions): void; - public moveEditor(input: IEditorInput, from: any, to: any, moveOptions?: IMoveOptions): void { - } - - public getStacksModel() { - return this.stacksModel; - } - - public getTabOptions(): IEditorTabOptions { - return {}; - } - - public invokeWithinEditorContext(fn: (accessor: ServicesAccessor) => T): T { - return fn(null); - } -} - -export class TestEditorService implements IWorkbenchEditorService { - public _serviceBrand: any; - - public activeEditorInput: IEditorInput; - public activeEditorOptions: IEditorOptions; - public activeEditorPosition: Position; - public mockLineNumber: number; - public mockSelectedText: string; - - private callback: (method: string) => void; - - constructor(callback?: (method: string) => void) { - this.callback = callback || ((s: string) => { }); - this.mockLineNumber = 15; - this.mockSelectedText = 'selected text'; - } - - public openEditors(inputs: any[]): Promise { - return TPromise.as([]); - } - - public replaceEditors(editors: any[]): TPromise { - return TPromise.as([]); - } - - public closeEditors(positions?: Position[]): TPromise; - public closeEditors(position: Position, filter?: ICloseEditorsFilter): TPromise; - public closeEditors(position: Position, editors: IEditorInput[]): TPromise; - public closeEditors(editors: { positionOne?: ICloseEditorsFilter, positionTwo?: ICloseEditorsFilter, positionThree?: ICloseEditorsFilter }): TPromise; - public closeEditors(editors: { positionOne?: IEditorInput[], positionTwo?: IEditorInput[], positionThree?: IEditorInput[] }): TPromise; - public closeEditors(positionOrEditors: any, filterOrEditors?: any): TPromise { - return TPromise.as(null); - } - - public getActiveEditor(): IEditor { - this.callback('getActiveEditor'); - - return { - input: null, - options: null, - group: null, - getId: () => { return null; }, - getControl: () => { - return { - getSelection: () => { return { positionLineNumber: this.mockLineNumber }; }, - getModel: () => { return { getValueInRange: () => this.mockSelectedText }; } - }; - }, - focus: () => { }, - isVisible: () => { return true; } - }; - } - - public getActiveEditorInput(): IEditorInput { - this.callback('getActiveEditorInput'); - - return this.activeEditorInput; - } - - public getVisibleEditors(): IEditor[] { - this.callback('getVisibleEditors'); - - return []; - } - - public openEditor(input: any, options?: any, position?: any): Promise { - this.callback('openEditor'); - - this.activeEditorInput = input; - this.activeEditorOptions = options; - this.activeEditorPosition = position; - - return TPromise.as(null); - } - - public closeEditor(position: Position, input: IEditorInput): TPromise { - this.callback('closeEditor'); - - return TPromise.as(null); - } - - public createInput(input: IResourceInput): IEditorInput { - return null; - } -} - -export class TestNextEditorGroupsService implements INextEditorGroupsService { +export class TestEditorGroupsService implements INextEditorGroupsService { _serviceBrand: ServiceIdentifier; - constructor(public groups: TestNextEditorGroup[] = []) { } + constructor(public groups: TestEditorGroup[] = []) { } onDidActiveGroupChange: Event = Event.None; onDidAddGroup: Event = Event.None; @@ -778,7 +572,7 @@ export class TestNextEditorGroupsService implements INextEditorGroupsService { } } -export class TestNextEditorGroup implements IEditorGroup { +export class TestEditorGroup implements IEditorGroup { constructor(public id: number) { } @@ -857,7 +651,7 @@ export class TestNextEditorGroup implements IEditorGroup { } } -export class TestNextEditorService implements INextEditorService { +export class TestEditorService implements INextEditorService { _serviceBrand: ServiceIdentifier;