提交 e66065b4 编写于 作者: B Benjamin Pasero

grid - fire active/visible editor change event on statup as before

上级 963a04e2
......@@ -8,7 +8,7 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { GroupIdentifier, IWorkbenchEditorConfiguration, IWorkbenchEditorPartConfiguration, EditorOptions, TextEditorOptions, IEditorInput, IEditorIdentifier, IEditorCloseEvent } from 'vs/workbench/common/editor';
import { EditorGroup } from 'vs/workbench/common/editor/editorGroup';
import { IEditorGroup, GroupDirection, IAddGroupOptions, IMergeGroupOptions, GroupsOrder } from 'vs/workbench/services/group/common/editorGroupsService';
import { IEditorGroup, GroupDirection, IAddGroupOptions, IMergeGroupOptions, GroupsOrder, IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Dimension } from 'vs/base/browser/dom';
import { Event } from 'vs/base/common/event';
......@@ -136,7 +136,7 @@ export function getActiveTextEditorOptions(group: IEditorGroup, expectedActiveEd
* A sub-interface of IEditorService to hide some workbench-core specific
* events from clients.
*/
export interface IEditorPartService extends IEditorService {
export interface IEditorServiceImpl extends IEditorService {
/**
* Emitted when an editor is closed.
......@@ -147,4 +147,16 @@ export interface IEditorPartService extends IEditorService {
* Emitted when an editor failed to open.
*/
readonly onDidOpenEditorFail: Event<IEditorIdentifier>;
}
/**
* A sub-interface of IEditorGroupsService to hide some workbench-core specific
* methods from clients.
*/
export interface IEditorGroupsServiceImpl extends IEditorGroupsService {
/**
* A promise that resolves when groups have been restored.
*/
readonly whenRestored: TPromise<void>;
}
\ No newline at end of file
......@@ -57,7 +57,6 @@ import { Schemas } from 'vs/base/common/network';
import { IAnchor } from 'vs/base/browser/ui/contextview/contextview';
import { Themable } from 'vs/workbench/common/theme';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
class SideBySideEditorEncodingSupport implements IEncodingSupport {
constructor(private master: IEncodingSupport, private details: IEncodingSupport) { }
......@@ -296,7 +295,6 @@ export class EditorStatus implements IStatusbarItem {
constructor(
@IEditorService private editorService: IEditorService,
@IEditorGroupsService private editorGroupService: IEditorGroupsService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IInstantiationService private instantiationService: IInstantiationService,
@IUntitledEditorService private untitledEditorService: IUntitledEditorService,
......@@ -371,8 +369,6 @@ export class EditorStatus implements IStatusbarItem {
TabFocus.onDidChangeTabFocus(e => this.onTabFocusModeChange()),
);
this.editorGroupService.whenRestored.then(() => this.updateStatusBar());
return combinedDisposable(this.toDispose);
}
......
......@@ -76,7 +76,7 @@ export class TitlebarPart extends Part implements ITitleService {
this.toUnbind.push(addDisposableListener(window, EventType.BLUR, () => this.onBlur()));
this.toUnbind.push(addDisposableListener(window, EventType.FOCUS, () => this.onFocus()));
this.toUnbind.push(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationChanged(e)));
this.toUnbind.push(this.editorService.onDidActiveEditorChange(() => this.updateFromActiveEditor()));
this.toUnbind.push(this.editorService.onDidActiveEditorChange(() => this.onActiveEditorChange()));
this.toUnbind.push(this.contextService.onDidChangeWorkspaceFolders(() => this.setTitle(this.getWindowTitle())));
this.toUnbind.push(this.contextService.onDidChangeWorkbenchState(() => this.setTitle(this.getWindowTitle())));
this.toUnbind.push(this.contextService.onDidChangeWorkspaceName(() => this.setTitle(this.getWindowTitle())));
......@@ -98,7 +98,7 @@ export class TitlebarPart extends Part implements ITitleService {
}
}
private updateFromActiveEditor(): void {
private onActiveEditorChange(): void {
// Dispose old listeners
dispose(this.activeEditorListeners);
......
......@@ -45,7 +45,7 @@ import { IIntegrityService } from 'vs/platform/integrity/common/integrity';
import { AccessibilitySupport, isRootUser, isWindows, isMacintosh } from 'vs/base/common/platform';
import product from 'vs/platform/node/product';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IEditorPartService } from 'vs/workbench/browser/parts/editor/editor';
import { IEditorServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
const TextInputActions: IAction[] = [
new Action('undo', nls.localize('undo', "Undo"), null, true, () => document.execCommand('undo') && TPromise.as(true)),
......@@ -72,7 +72,7 @@ export class ElectronWindow extends Themable {
constructor(
shellContainer: HTMLElement,
@IEditorService private editorService: IEditorPartService,
@IEditorService private editorService: IEditorServiceImpl,
@IWindowsService private windowsService: IWindowsService,
@IWindowService private windowService: IWindowService,
@IWorkspaceConfigurationService private configurationService: IWorkspaceConfigurationService,
......@@ -295,9 +295,6 @@ export class ElectronWindow extends Themable {
ipc.send('vscode:workbenchLoaded', this.windowService.getCurrentWindowId());
});
// Touchbar Support
this.updateTouchbarMenu();
// Integrity warning
this.integrityService.isPure().then(res => this.titleService.updateProperties({ isPure: res.isPure }));
......
......@@ -598,8 +598,6 @@ export class Workbench extends Disposable implements IPartService {
}
};
this.editorGroupService.whenRestored.then(() => updateEditorContextKeys());
this._register(this.editorService.onDidActiveEditorChange(() => updateEditorContextKeys()));
this._register(this.editorService.onDidVisibleEditorsChange(() => updateEditorContextKeys()));
this._register(this.editorGroupService.onDidAddGroup(() => updateEditorContextKeys()));
......@@ -643,7 +641,7 @@ export class Workbench extends Disposable implements IPartService {
// Restore Editorpart
perf.mark('willRestoreEditors');
restorePromises.push(this.editorGroupService.whenRestored.then(() => {
restorePromises.push(this.editorPart.whenRestored.then(() => {
return this.resolveEditorsToOpen().then(inputs => {
if (inputs.length) {
return this.editorService.openEditors(inputs);
......
......@@ -30,7 +30,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { Disposable, IDisposable, dispose, toDisposable } from 'vs/base/common/lifecycle';
import { coalesce } from 'vs/base/common/arrays';
import { isCodeEditor, isDiffEditor, ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
import { IEditorGroupView, IEditorOpeningEvent } from 'vs/workbench/browser/parts/editor/editor';
import { IEditorGroupView, IEditorOpeningEvent, IEditorGroupsServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
type ICachedEditorInput = ResourceEditorInput | IFileEditorInput | DataUriEditorInput;
......@@ -63,7 +63,7 @@ export class EditorService extends Disposable implements IEditorService {
private lastActiveGroupId: GroupIdentifier;
constructor(
@IEditorGroupsService private editorGroupService: IEditorGroupsService,
@IEditorGroupsService private editorGroupService: IEditorGroupsServiceImpl,
@IUntitledEditorService private untitledEditorService: IUntitledEditorService,
@IWorkspaceContextService private workspaceContextService: IWorkspaceContextService,
@IInstantiationService private instantiationService: IInstantiationService,
......@@ -79,11 +79,23 @@ export class EditorService extends Disposable implements IEditorService {
}
private registerListeners(): void {
this.editorGroupService.whenRestored.then(() => this.editorGroupService.groups.forEach(group => this.registerGroupListeners(group as IEditorGroupView)));
this.editorGroupService.whenRestored.then(() => this.onEditorsRestored());
this.editorGroupService.onDidActiveGroupChange(group => this.handleActiveEditorChange(group));
this.editorGroupService.onDidAddGroup(group => this.registerGroupListeners(group as IEditorGroupView));
}
private onEditorsRestored(): void {
// Register listeners to each opened group
this.editorGroupService.groups.forEach(group => this.registerGroupListeners(group as IEditorGroupView));
// Fire initial set of editor events if there is an active editor
if (this.activeEditor) {
this.doEmitActiveEditorChangeEvent();
this._onDidVisibleEditorsChange.fire();
}
}
private handleActiveEditorChange(group: IEditorGroup): void {
if (group !== this.editorGroupService.activeGroup) {
return; // ignore if not the active group
......@@ -97,8 +109,14 @@ export class EditorService extends Disposable implements IEditorService {
return; // ignore if the editor actually did not change
}
this.lastActiveGroupId = group.id;
this.lastActiveEditor = group.activeEditor;
this.doEmitActiveEditorChangeEvent();
}
private doEmitActiveEditorChangeEvent(): void {
const activeGroup = this.editorGroupService.activeGroup;
this.lastActiveGroupId = activeGroup.id;
this.lastActiveEditor = activeGroup.activeEditor;
this._onDidActiveEditorChange.fire();
}
......@@ -580,7 +598,7 @@ export class DelegatingWorkbenchEditorService extends EditorService {
private editorOpenHandler: IEditorOpenHandler;
constructor(
@IEditorGroupsService editorGroupService: IEditorGroupsService,
@IEditorGroupsService editorGroupService: IEditorGroupsServiceImpl,
@IUntitledEditorService untitledEditorService: IUntitledEditorService,
@IWorkspaceContextService workspaceContextService: IWorkspaceContextService,
@IInstantiationService instantiationService: IInstantiationService,
......
......@@ -29,7 +29,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
import { IEditorPartService } from 'vs/workbench/browser/parts/editor/editor';
import { IEditorServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
export class TestEditorControl extends BaseEditor {
......@@ -75,7 +75,7 @@ suite('Editor service', () => {
const testInstantiationService = partInstantiator.createChild(new ServiceCollection([IEditorGroupsService, part]));
const service: IEditorPartService = testInstantiationService.createInstance(EditorService);
const service: IEditorServiceImpl = testInstantiationService.createInstance(EditorService);
const input = testInstantiationService.createInstance(TestEditorInput, URI.parse('my://resource'));
const otherInput = testInstantiationService.createInstance(TestEditorInput, URI.parse('my://resource2'));
......@@ -443,7 +443,7 @@ suite('Editor service', () => {
const testInstantiationService = partInstantiator.createChild(new ServiceCollection([IEditorGroupsService, part]));
const service: IEditorPartService = testInstantiationService.createInstance(EditorService);
const service: IEditorServiceImpl = testInstantiationService.createInstance(EditorService);
const input = testInstantiationService.createInstance(TestEditorInput, URI.parse('my://resource'));
const otherInput = testInstantiationService.createInstance(TestEditorInput, URI.parse('my://resource2'));
......
......@@ -182,11 +182,6 @@ export interface IEditorGroupsService {
*/
readonly orientation: GroupOrientation;
/**
* A promise that resolves when groups have been restored.
*/
readonly whenRestored: TPromise<void>;
/**
* Get all groups that are currently visible in the editor area optionally
* sorted by being most recent active or grid order. Will sort by creation
......
......@@ -31,7 +31,7 @@ import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorE
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ResourceGlobMatcher } from 'vs/workbench/electron-browser/resources';
import { Schemas } from 'vs/base/common/network';
import { IEditorPartService } from 'vs/workbench/browser/parts/editor/editor';
import { IEditorServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
/**
* Stores the selection & view state of an editor and allows to compare it to other selection states.
......@@ -125,7 +125,7 @@ export class HistoryService implements IHistoryService {
private fileInputFactory: IFileInputFactory;
constructor(
@IEditorService private editorService: IEditorPartService,
@IEditorService private editorService: IEditorServiceImpl,
@IEditorGroupsService private editorGroupService: IEditorGroupsService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IStorageService private storageService: IStorageService,
......
......@@ -15,7 +15,7 @@ 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 { ConfirmResult, IEditorInputWithOptions, CloseDirection, IEditorIdentifier, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInput, IEditor, IEditorCloseEvent } from 'vs/workbench/common/editor';
import { IEditorOpeningEvent, IEditorPartService, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
import { IEditorOpeningEvent, IEditorServiceImpl, IEditorGroupView, IEditorGroupsServiceImpl } from 'vs/workbench/browser/parts/editor/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';
......@@ -494,7 +494,7 @@ export class TestStorageService implements IStorageService {
}
}
export class TestEditorGroupsService implements IEditorGroupsService {
export class TestEditorGroupsService implements IEditorGroupsServiceImpl {
_serviceBrand: ServiceIdentifier<any>;
constructor(public groups: TestEditorGroup[] = []) { }
......@@ -669,7 +669,7 @@ export class TestEditorGroup implements IEditorGroupView {
layout(width: number, height: number): void { }
}
export class TestEditorService implements IEditorPartService {
export class TestEditorService implements IEditorServiceImpl {
_serviceBrand: ServiceIdentifier<any>;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册