revert some things for #45527 that do not work anymore

This commit is contained in:
Benjamin Pasero 2018-03-13 07:28:01 +01:00
parent 112670122d
commit 62cfab535c
3 changed files with 3 additions and 56 deletions

View file

@ -20,7 +20,7 @@ import { EventType as TouchEventType, GestureEvent, Gesture } from 'vs/base/brow
import { KeyCode } from 'vs/base/common/keyCodes';
import { ResourceLabel } from 'vs/workbench/browser/labels';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { IWorkbenchEditorService, DelegatingWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
@ -34,7 +34,6 @@ import { IDisposable, dispose, combinedDisposable } from 'vs/base/common/lifecyc
import { ScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
import { getOrSet } from 'vs/base/common/map';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IThemeService, registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
import { TAB_INACTIVE_BACKGROUND, TAB_ACTIVE_BACKGROUND, TAB_ACTIVE_FOREGROUND, TAB_INACTIVE_FOREGROUND, TAB_BORDER, EDITOR_DRAG_AND_DROP_BACKGROUND, TAB_UNFOCUSED_ACTIVE_FOREGROUND, TAB_UNFOCUSED_INACTIVE_FOREGROUND, TAB_UNFOCUSED_ACTIVE_BORDER, TAB_ACTIVE_BORDER, TAB_HOVER_BACKGROUND, TAB_HOVER_BORDER, TAB_UNFOCUSED_HOVER_BACKGROUND, TAB_UNFOCUSED_HOVER_BORDER, EDITOR_GROUP_HEADER_TABS_BACKGROUND, EDITOR_GROUP_BACKGROUND, WORKBENCH_BACKGROUND } from 'vs/workbench/common/theme';
import { activeContrastBorder, contrastBorder, editorBackground } from 'vs/platform/theme/common/colorRegistry';
@ -84,34 +83,6 @@ export class TabsTitleControl extends TitleControl {
this.editorLabels = [];
}
protected initActions(services: IInstantiationService): void {
super.initActions(this.createScopedInstantiationService());
}
private createScopedInstantiationService(): IInstantiationService {
const stacks = this.editorGroupService.getStacksModel();
const delegatingEditorService = this.instantiationService.createInstance(DelegatingWorkbenchEditorService);
// We create a scoped instantiation service to override the behaviour when closing an inactive editor
// Specifically we want to move focus back to the editor when an inactive editor is closed from anywhere
// in the tabs title control (e.g. mouse middle click, context menu on tab). This is only needed for
// the inactive editors because closing the active one will always cause a tab switch that sets focus.
// We also want to block the tabs container to reveal the currently active tab because that makes it very
// hard to close multiple inactive tabs next to each other.
delegatingEditorService.setEditorCloseHandler((position, editor) => {
const group = stacks.groupAt(position);
if (group && stacks.isActive(group) && !group.isActive(editor)) {
this.editorGroupService.focusGroup(group);
}
this.blockRevealActiveTab = true;
return TPromise.as(void 0);
});
return this.instantiationService.createChild(new ServiceCollection([IWorkbenchEditorService, delegatingEditorService]));
}
public create(parent: HTMLElement): void {
super.create(parent);

View file

@ -268,10 +268,6 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
}
public closeEditor(position: Position, input: IEditorInput): TPromise<void> {
return this.doCloseEditor(position, input);
}
protected doCloseEditor(position: Position, input: IEditorInput): TPromise<void> {
return this.editorPart.closeEditor(position, input);
}
@ -400,7 +396,6 @@ export interface IEditorCloseHandler {
*/
export class DelegatingWorkbenchEditorService extends WorkbenchEditorService {
private editorOpenHandler: IEditorOpenHandler;
private editorCloseHandler: IEditorCloseHandler;
constructor(
@IUntitledEditorService untitledEditorService: IUntitledEditorService,
@ -424,10 +419,6 @@ export class DelegatingWorkbenchEditorService extends WorkbenchEditorService {
this.editorOpenHandler = handler;
}
public setEditorCloseHandler(handler: IEditorCloseHandler): void {
this.editorCloseHandler = handler;
}
protected doOpenEditor(input: IEditorInput, options?: EditorOptions, sideBySide?: boolean): TPromise<IEditor>;
protected doOpenEditor(input: IEditorInput, options?: EditorOptions, position?: Position): TPromise<IEditor>;
protected doOpenEditor(input: IEditorInput, options?: EditorOptions, arg3?: any): TPromise<IEditor> {
@ -441,12 +432,4 @@ export class DelegatingWorkbenchEditorService extends WorkbenchEditorService {
return super.doOpenEditor(input, options, arg3);
});
}
protected doCloseEditor(position: Position, input: IEditorInput): TPromise<void> {
const handleClose = this.editorCloseHandler ? this.editorCloseHandler(position, input) : TPromise.as(void 0);
return handleClose.then(() => {
return super.doCloseEditor(position, input);
});
}
}

View file

@ -266,18 +266,11 @@ suite('WorkbenchEditorService', () => {
delegate.setEditorOpenHandler((input: IEditorInput, options?: EditorOptions) => {
assert.strictEqual(input, inp);
done();
return TPromise.as(ed);
});
delegate.setEditorCloseHandler((position, input) => {
assert.strictEqual(input, inp);
done();
return TPromise.as(void 0);
});
delegate.openEditor(inp);
delegate.closeEditor(0, inp);
});
});