提交 540a57ef 编写于 作者: B Benjamin Pasero

grid - adopt IOpenEditorEvent

上级 d3082d70
......@@ -22,17 +22,6 @@ export interface IEditorService {
openEditor(input: IResourceInput, sideBySide?: boolean): TPromise<IEditor>;
}
export interface IEditorInputWithOptions {
editor: IEditorInput;
options?: IEditorOptions;
}
export function isEditorInputWithOptions(obj: any): obj is IEditorInputWithOptions {
const editorInputWithOptions = obj as IEditorInputWithOptions;
return !!editorInputWithOptions && !!editorInputWithOptions.editor;
}
export interface IEditorModel {
onDispose: Event<void>;
......
......@@ -947,11 +947,11 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
}
// Editor opening event (can be prevented and overridden)
const event = new EditorOpeningEvent(input, options, position);
const event = new EditorOpeningEvent(null, input, options);
this._onEditorOpening.fire(event);
const prevented = event.isPrevented();
if (prevented) {
return prevented();
return prevented() as any;
}
// Open through UI
......
......@@ -582,11 +582,11 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
openEditor(editor: EditorInput, options?: EditorOptions): Thenable<void> {
// Editor opening event allows for prevention
const event = new EditorOpeningEvent(editor, options, this._group.id); // TODO@grid position => group ID
const event = new EditorOpeningEvent(this, editor, options);
this._onWillOpenEditor.fire(event);
const prevented = event.isPrevented();
if (prevented) {
return prevented().then(() => void 0); // TODO@grid do we need the BaseEditor return type still in the event?
return prevented();
}
// Proceed with opening
......
......@@ -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, IEditorViewState, ScrollType } from 'vs/editor/common/editorCommon';
import { IEditorInput, IEditorModel, IEditorOptions, ITextEditorOptions, IBaseResourceInput, Position, Verbosity, IEditor as IBaseEditor, IRevertOptions } from 'vs/platform/editor/common/editor';
import { IEditorInput, IEditorModel, IEditorOptions, ITextEditorOptions, IBaseResourceInput, Position, Verbosity, IRevertOptions } 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';
......@@ -274,9 +274,9 @@ export abstract class EditorInput implements IEditorInput {
}
export interface IEditorOpeningEvent {
input: IEditorInput;
editor: IEditorInput;
options?: IEditorOptions;
position: Position;
group: INextEditorGroup;
/**
* Allows to prevent the opening of an editor by providing a callback
......@@ -285,32 +285,32 @@ export interface IEditorOpeningEvent {
* to return a promise that resolves to NULL to prevent the opening
* altogether.
*/
prevent(callback: () => TPromise<IBaseEditor>): void;
prevent(callback: () => Thenable<any>): void;
}
export class EditorOpeningEvent implements IEditorOpeningEvent {
private override: () => TPromise<IBaseEditor>;
private override: () => Thenable<any>;
constructor(private _input: IEditorInput, private _options: IEditorOptions, private _position: Position) {
constructor(private _group: INextEditorGroup, private _editor: IEditorInput, private _options: IEditorOptions) {
}
public get input(): IEditorInput {
return this._input;
public get group(): INextEditorGroup {
return this._group;
}
public get options(): IEditorOptions {
return this._options;
public get editor(): IEditorInput {
return this._editor;
}
public get position(): Position {
return this._position;
public get options(): IEditorOptions {
return this._options;
}
public prevent(callback: () => TPromise<IBaseEditor>): void {
public prevent(callback: () => Thenable<any>): void {
this.override = callback;
}
public isPrevented(): () => TPromise<IBaseEditor> {
public isPrevented(): () => Thenable<any> {
return this.override;
}
}
......@@ -519,6 +519,17 @@ export class EditorModel extends Disposable implements IEditorModel {
}
}
export interface IEditorInputWithOptions {
editor: IEditorInput;
options?: IEditorOptions;
}
export function isEditorInputWithOptions(obj: any): obj is IEditorInputWithOptions {
const editorInputWithOptions = obj as IEditorInputWithOptions;
return !!editorInputWithOptions && !!editorInputWithOptions.editor;
}
/**
* The editor options is the base class of options that can be passed in when opening an editor.
*/
......
......@@ -1104,13 +1104,13 @@ export class GlobalCompareResourcesAction extends Action {
// Compare with next editor that opens
const unbind = once(this.editorGroupService.onEditorOpening)(e => {
const resource = e.input.getResource();
const resource = e.editor.getResource();
if (resource) {
e.prevent(() => {
return this.editorService.openEditor({
leftResource: activeResource,
rightResource: resource
});
}).then(() => void 0);
});
}
});
......
......@@ -60,7 +60,7 @@ export class PreferencesContribution implements IWorkbenchContribution {
}
private onEditorOpening(event: IEditorOpeningEvent): void {
const resource = event.input.getResource();
const resource = event.editor.getResource();
if (
!resource || resource.scheme !== 'file' || // require a file path opening
!endsWith(resource.fsPath, 'settings.json') || // file must end in settings.json
......@@ -72,15 +72,13 @@ export class PreferencesContribution implements IWorkbenchContribution {
// If the file resource was already opened before in the group, do not prevent
// the opening of that resource. Otherwise we would have the same settings
// opened twice (https://github.com/Microsoft/vscode/issues/36447)
const stacks = this.editorGroupService.getStacksModel();
const group = stacks.groupAt(event.position);
if (group && group.contains(event.input)) {
if (event.group.isOpened(event.editor)) {
return;
}
// Global User Settings File
if (resource.fsPath === this.environmentService.appSettingsPath) {
return event.prevent(() => this.preferencesService.openGlobalSettings(event.options, event.position));
return event.prevent(() => this.preferencesService.openGlobalSettings(event.options, event.group));
}
// Single Folder Workspace Settings File
......@@ -88,7 +86,7 @@ export class PreferencesContribution implements IWorkbenchContribution {
if (state === WorkbenchState.FOLDER) {
const folders = this.workspaceService.getWorkspace().folders;
if (resource.fsPath === folders[0].toResource(FOLDER_SETTINGS_PATH).fsPath) {
return event.prevent(() => this.preferencesService.openWorkspaceSettings(event.options, event.position));
return event.prevent(() => this.preferencesService.openWorkspaceSettings(event.options, event.group));
}
}
......@@ -97,7 +95,7 @@ export class PreferencesContribution implements IWorkbenchContribution {
const folders = this.workspaceService.getWorkspace().folders;
for (let i = 0; i < folders.length; i++) {
if (resource.fsPath === folders[i].toResource(FOLDER_SETTINGS_PATH).fsPath) {
return event.prevent(() => this.preferencesService.openFolderSettings(folders[i].uri, event.options, event.position));
return event.prevent(() => this.preferencesService.openFolderSettings(folders[i].uri, event.options, event.group));
}
}
}
......
......@@ -6,8 +6,8 @@
'use strict';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IEditorInput, IResourceInput, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditor, ITextEditorOptions, IEditorOptions, IEditorInputWithOptions, isEditorInputWithOptions } from 'vs/platform/editor/common/editor';
import { GroupIdentifier, IFileEditorInput, IEditorInputFactoryRegistry, Extensions as EditorExtensions, IFileInputFactory, EditorInput, SideBySideEditorInput, EditorOptions, TextEditorOptions, IEditorOpeningEvent } from 'vs/workbench/common/editor';
import { IEditorInput, IResourceInput, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditor, ITextEditorOptions, IEditorOptions } from 'vs/platform/editor/common/editor';
import { GroupIdentifier, IFileEditorInput, IEditorInputFactoryRegistry, Extensions as EditorExtensions, IFileInputFactory, EditorInput, SideBySideEditorInput, IEditorInputWithOptions, isEditorInputWithOptions, EditorOptions, TextEditorOptions, IEditorOpeningEvent } from 'vs/workbench/common/editor';
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
import { DataUriEditorInput } from 'vs/workbench/common/editor/dataUriEditorInput';
import { Registry } from 'vs/platform/registry/common/platform';
......@@ -163,9 +163,9 @@ export class NextEditorService extends Disposable implements INextEditorService
//#region openEditor()
openEditor(editor: IEditorInput, options?: IEditorOptions, group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<IEditor>;
openEditor(editor: IResourceEditor, group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<IEditor>;
openEditor(editor: IEditorInput | IResourceEditor, optionsOrGroup?: IEditorOptions | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE, group?: GroupIdentifier): Thenable<IEditor> {
openEditor(editor: IEditorInput, options?: IEditorOptions, group?: INextEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<IEditor>;
openEditor(editor: IResourceEditor, group?: INextEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<IEditor>;
openEditor(editor: IEditorInput | IResourceEditor, optionsOrGroup?: IEditorOptions | INextEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE, group?: GroupIdentifier): Thenable<IEditor> {
// Typed Editor Support
if (editor instanceof EditorInput) {
......@@ -189,7 +189,7 @@ export class NextEditorService extends Disposable implements INextEditorService
const typedInput = this.createInput(textInput);
if (typedInput) {
const editorOptions = TextEditorOptions.from(textInput);
const targetGroup = this.findTargetGroup(typedInput, editorOptions, optionsOrGroup as GroupIdentifier);
const targetGroup = this.findTargetGroup(typedInput, editorOptions, optionsOrGroup as INextEditorGroup | GroupIdentifier);
return targetGroup.openEditor(typedInput, editorOptions).then(() => targetGroup.activeControl);
}
......@@ -197,9 +197,14 @@ export class NextEditorService extends Disposable implements INextEditorService
return TPromise.wrap<IEditor>(null);
}
private findTargetGroup(input: IEditorInput, options?: IEditorOptions, group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): INextEditorGroup {
private findTargetGroup(input: IEditorInput, options?: IEditorOptions, group?: INextEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): INextEditorGroup {
let targetGroup: INextEditorGroup;
// Group: Instance of Group
if (group && typeof group !== 'number') {
return group;
}
// Group: Active Group
if (group === ACTIVE_GROUP) {
targetGroup = this.nextEditorGroupsService.activeGroup;
......@@ -271,9 +276,9 @@ export class NextEditorService extends Disposable implements INextEditorService
//#region openEditors()
openEditors(editors: IEditorInputWithOptions[], group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<IEditor[]>;
openEditors(editors: IResourceEditor[], group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<IEditor[]>;
openEditors(editors: (IEditorInputWithOptions | IResourceEditor)[], group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<IEditor[]> {
openEditors(editors: IEditorInputWithOptions[], group?: INextEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<IEditor[]>;
openEditors(editors: IResourceEditor[], group?: INextEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<IEditor[]>;
openEditors(editors: (IEditorInputWithOptions | IResourceEditor)[], group?: INextEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<IEditor[]> {
// Convert to typed editors and options
const typedEditors: IEditorInputWithOptions[] = [];
......
......@@ -6,10 +6,11 @@
'use strict';
import { createDecorator, ServiceIdentifier, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IEditorInput, IResourceInput, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditor, IEditorOptions, IEditorInputWithOptions } from 'vs/platform/editor/common/editor';
import { GroupIdentifier, IEditorOpeningEvent } from 'vs/workbench/common/editor';
import { IEditorInput, IResourceInput, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditor, IEditorOptions } from 'vs/platform/editor/common/editor';
import { GroupIdentifier, IEditorOpeningEvent, IEditorInputWithOptions } from 'vs/workbench/common/editor';
import { Event } from 'vs/base/common/event';
import { IEditor as ICodeEditor } from 'vs/editor/common/editorCommon';
import { INextEditorGroup } from 'vs/workbench/services/group/common/nextEditorGroupsService';
export const INextEditorService = createDecorator<INextEditorService>('nextEditorService');
......@@ -90,7 +91,7 @@ export interface INextEditorService {
* active group. Use `SIDE_GROUP_TYPE` to open the editor in a new editor group to the side
* of the currently active group.
*/
openEditor(editor: IEditorInput, options?: IEditorOptions, group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<IEditor>;
openEditor(editor: IEditorInput, options?: IEditorOptions, group?: INextEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<IEditor>;
/**
* Open an editor in an editor group.
......@@ -100,7 +101,7 @@ export interface INextEditorService {
* active group. Use `SIDE_GROUP_TYPE` to open the editor in a new editor group to the side
* of the currently active group.
*/
openEditor(editor: IResourceEditor, group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<IEditor>;
openEditor(editor: IResourceEditor, group?: INextEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<IEditor>;
/**
* Open editors in an editor group.
......@@ -110,8 +111,8 @@ export interface INextEditorService {
* active group. Use `SIDE_GROUP_TYPE` to open the editor in a new editor group to the side
* of the currently active group.
*/
openEditors(editors: IEditorInputWithOptions[], group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<ReadonlyArray<IEditor>>;
openEditors(editors: IResourceEditor[], group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<ReadonlyArray<IEditor>>;
openEditors(editors: IEditorInputWithOptions[], group?: INextEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<ReadonlyArray<IEditor>>;
openEditors(editors: IResourceEditor[], group?: INextEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable<ReadonlyArray<IEditor>>;
/**
* Find out if the provided editor (or resource of an editor) is opened in any group.
......
......@@ -7,8 +7,8 @@
import { Event } from 'vs/base/common/event';
import { createDecorator, ServiceIdentifier, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { GroupIdentifier, IEditorOpeningEvent } from 'vs/workbench/common/editor';
import { IEditorInput, IEditor, IEditorOptions, IEditorInputWithOptions, Direction } from 'vs/platform/editor/common/editor';
import { GroupIdentifier, IEditorOpeningEvent, IEditorInputWithOptions } from 'vs/workbench/common/editor';
import { IEditorInput, IEditor, IEditorOptions, Direction } from 'vs/platform/editor/common/editor';
export const INextEditorGroupsService = createDecorator<INextEditorGroupsService>('nextEditorGroupsService');
......
......@@ -39,6 +39,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { assign } from 'vs/base/common/objects';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorGroup, INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
const emptyEditableSettingsContent = '{\n}';
......@@ -61,6 +62,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private nextEditorService: INextEditorService,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@INextEditorGroupsService private nextEditorGroupService: INextEditorGroupsService,
@IFileService private fileService: IFileService,
@IWorkspaceConfigurationService private configurationService: IWorkspaceConfigurationService,
@INotificationService private notificationService: INotificationService,
......@@ -181,30 +183,30 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return this.openOrSwitchSettings(target, resource);
}
openGlobalSettings(options?: IEditorOptions, position?: EditorPosition): TPromise<IEditor> {
return this.openOrSwitchSettings(ConfigurationTarget.USER, this.userSettingsResource, options, position);
openGlobalSettings(options?: IEditorOptions, group?: INextEditorGroup): TPromise<IEditor> {
return this.openOrSwitchSettings(ConfigurationTarget.USER, this.userSettingsResource, options, group);
}
openSettings2(): TPromise<IEditor> {
return this.editorService.openEditor(this.instantiationService.createInstance(SettingsEditor2Input), { pinned: true }).then(() => null);
}
openWorkspaceSettings(options?: IEditorOptions, position?: EditorPosition): TPromise<IEditor> {
openWorkspaceSettings(options?: IEditorOptions, group?: INextEditorGroup): TPromise<IEditor> {
if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) {
this.notificationService.info(nls.localize('openFolderFirst', "Open a folder first to create workspace settings"));
return TPromise.as(null);
}
return this.openOrSwitchSettings(ConfigurationTarget.WORKSPACE, this.workspaceSettingsResource, options, position);
return this.openOrSwitchSettings(ConfigurationTarget.WORKSPACE, this.workspaceSettingsResource, options, group);
}
openFolderSettings(folder: URI, options?: IEditorOptions, position?: EditorPosition): TPromise<IEditor> {
return this.openOrSwitchSettings(ConfigurationTarget.WORKSPACE_FOLDER, this.getEditableSettingsURI(ConfigurationTarget.WORKSPACE_FOLDER, folder), options, position);
openFolderSettings(folder: URI, options?: IEditorOptions, group?: INextEditorGroup): TPromise<IEditor> {
return this.openOrSwitchSettings(ConfigurationTarget.WORKSPACE_FOLDER, this.getEditableSettingsURI(ConfigurationTarget.WORKSPACE_FOLDER, folder), options, group);
}
switchSettings(target: ConfigurationTarget, resource: URI): TPromise<void> {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor && activeEditor.input instanceof PreferencesEditorInput) {
return this.doSwitchSettings(target, resource, activeEditor.input, activeEditor.position).then(() => null);
return this.doSwitchSettings(target, resource, activeEditor.input, null).then(() => null);
} else {
return this.doOpenSettings(target, resource).then(() => null);
}
......@@ -247,17 +249,15 @@ export class PreferencesService extends Disposable implements IPreferencesServic
});
}
private openOrSwitchSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: IEditorOptions, position?: EditorPosition): TPromise<IEditor> {
const activeGroup = this.editorGroupService.getStacksModel().activeGroup;
const positionToReplace = position !== void 0 ? position : activeGroup ? this.editorGroupService.getStacksModel().positionOfGroup(activeGroup) : EditorPosition.ONE;
const editorInput = this.getActiveSettingsEditorInput(positionToReplace);
private openOrSwitchSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: IEditorOptions, group: INextEditorGroup = this.nextEditorGroupService.activeGroup): TPromise<IEditor> {
const editorInput = this.getActiveSettingsEditorInput(group);
if (editorInput && editorInput.master.getResource().fsPath !== resource.fsPath) {
return this.doSwitchSettings(configurationTarget, resource, editorInput, positionToReplace);
return this.doSwitchSettings(configurationTarget, resource, editorInput, group);
}
return this.doOpenSettings(configurationTarget, resource, options, position);
return this.doOpenSettings(configurationTarget, resource, options, group);
}
private doOpenSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: IEditorOptions, position?: EditorPosition): TPromise<IEditor> {
private doOpenSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: IEditorOptions, group?: INextEditorGroup): TPromise<IEditor> {
const openDefaultSettings = !!this.configurationService.getValue(DEFAULT_SETTINGS_EDITOR_SETTING);
return this.getOrCreateEditableSettingsEditorInput(configurationTarget, resource)
.then(editableSettingsEditorInput => {
......@@ -271,30 +271,29 @@ export class PreferencesService extends Disposable implements IPreferencesServic
const defaultPreferencesEditorInput = this.instantiationService.createInstance(DefaultPreferencesEditorInput, this.getDefaultSettingsResource(configurationTarget));
const preferencesEditorInput = new PreferencesEditorInput(this.getPreferencesEditorInputName(configurationTarget, resource), editableSettingsEditorInput.getDescription(), defaultPreferencesEditorInput, <EditorInput>editableSettingsEditorInput);
this.lastOpenedSettingsInput = preferencesEditorInput;
return this.nextEditorService.openEditor(preferencesEditorInput, options /*, TODO@grid position */);
return this.nextEditorService.openEditor(preferencesEditorInput, options, group);
}
return this.nextEditorService.openEditor(editableSettingsEditorInput, options /*, TODO@grid position */);
return this.nextEditorService.openEditor(editableSettingsEditorInput, options, group);
});
}
private doSwitchSettings(target: ConfigurationTarget, resource: URI, input: PreferencesEditorInput, position?: EditorPosition): TPromise<IEditor> {
private doSwitchSettings(target: ConfigurationTarget, resource: URI, input: PreferencesEditorInput, group: INextEditorGroup): TPromise<IEditor> {
return this.getOrCreateEditableSettingsEditorInput(target, this.getEditableSettingsURI(target, resource))
.then(toInput => {
const replaceWith = new PreferencesEditorInput(this.getPreferencesEditorInputName(target, resource), toInput.getDescription(), this.instantiationService.createInstance(DefaultPreferencesEditorInput, this.getDefaultSettingsResource(target)), toInput);
return this.editorService.replaceEditors([{
toReplace: input,
replaceWith
}], position).then(editors => {
return group.replaceEditors([{
editor: input,
replacement: replaceWith
}]).then(() => {
this.lastOpenedSettingsInput = replaceWith;
return editors[0];
return group.activeControl;
});
});
}
private getActiveSettingsEditorInput(position?: EditorPosition): PreferencesEditorInput {
const stacksModel = this.editorGroupService.getStacksModel();
const group = position !== void 0 ? stacksModel.groupAt(position) : stacksModel.activeGroup;
return group && <PreferencesEditorInput>group.getEditors().filter(e => e instanceof PreferencesEditorInput)[0];
private getActiveSettingsEditorInput(group: INextEditorGroup = this.nextEditorGroupService.activeGroup): PreferencesEditorInput {
return <PreferencesEditorInput>group.editors.filter(e => e instanceof PreferencesEditorInput)[0];
}
private getConfigurationTargetFromSettingsResource(resource: URI): ConfigurationTarget {
......
......@@ -6,7 +6,7 @@
import URI from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IEditor, Position, IEditorOptions } from 'vs/platform/editor/common/editor';
import { IEditor, IEditorOptions } from 'vs/platform/editor/common/editor';
import { ITextModel } from 'vs/editor/common/model';
import { IRange } from 'vs/editor/common/core/range';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
......@@ -16,6 +16,7 @@ import { Event } from 'vs/base/common/event';
import { IStringDictionary } from 'vs/base/common/collections';
import { ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
import { localize } from 'vs/nls';
import { INextEditorGroup } from 'vs/workbench/services/group/common/nextEditorGroupsService';
export interface ISettingsGroup {
id: string;
......@@ -143,9 +144,9 @@ export interface IPreferencesService {
openRawDefaultSettings(): TPromise<void>;
openSettings(): TPromise<IEditor>;
openSettings2(): TPromise<IEditor>;
openGlobalSettings(options?: IEditorOptions, position?: Position): TPromise<IEditor>;
openWorkspaceSettings(options?: IEditorOptions, position?: Position): TPromise<IEditor>;
openFolderSettings(folder: URI, options?: IEditorOptions, position?: Position): TPromise<IEditor>;
openGlobalSettings(options?: IEditorOptions, group?: INextEditorGroup): TPromise<IEditor>;
openWorkspaceSettings(options?: IEditorOptions, group?: INextEditorGroup): TPromise<IEditor>;
openFolderSettings(folder: URI, options?: IEditorOptions, group?: INextEditorGroup): TPromise<IEditor>;
switchSettings(target: ConfigurationTarget, resource: URI): TPromise<void>;
openGlobalKeybindingSettings(textual: boolean): TPromise<void>;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册