editors - do not expose raw group from editor group view
This commit is contained in:
parent
5e33a56d23
commit
38f2172759
|
@ -4,7 +4,6 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { GroupIdentifier, IWorkbenchEditorConfiguration, EditorOptions, TextEditorOptions, IEditorInput, IEditorIdentifier, IEditorCloseEvent, IEditorPartOptions, IEditorPartOptionsChangeEvent, EditorInput, IEditorMoveEvent } from 'vs/workbench/common/editor';
|
||||
import { EditorGroup } from 'vs/workbench/common/editor/editorGroup';
|
||||
import { IEditorGroup, GroupDirection, IAddGroupOptions, IMergeGroupOptions, GroupsOrder, GroupsArrangement } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Dimension } from 'vs/base/browser/dom';
|
||||
|
@ -111,8 +110,6 @@ export interface IEditorGroupView extends IDisposable, ISerializableView, IEdito
|
|||
readonly onDidCloseEditor: Event<IEditorCloseEvent>;
|
||||
readonly onWillDispose: Event<void>;
|
||||
|
||||
readonly group: EditorGroup;
|
||||
|
||||
/**
|
||||
* A promise that resolves when the group has been restored.
|
||||
*
|
||||
|
|
|
@ -100,6 +100,8 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
|
||||
//#endregion
|
||||
|
||||
private readonly _group: EditorGroup;
|
||||
|
||||
private active: boolean | undefined;
|
||||
private dimension: Dimension | undefined;
|
||||
|
||||
|
@ -142,7 +144,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
super(themeService);
|
||||
|
||||
if (from instanceof EditorGroupView) {
|
||||
this._group = this._register(from.group.clone());
|
||||
this._group = this._register(from._group.clone());
|
||||
} else if (isSerializedEditorGroup(from)) {
|
||||
this._group = this._register(instantiationService.createInstance(EditorGroup, from));
|
||||
} else {
|
||||
|
@ -548,7 +550,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
// (including being visible in side by side / diff editors) and as such we
|
||||
// only dispose when they are not opened elsewhere.
|
||||
for (const editor of editorsToClose) {
|
||||
if (!this.accessor.groups.some(groupView => groupView.group.contains(editor, {
|
||||
if (!this.accessor.groups.some(groupView => groupView.contains(editor, {
|
||||
strictEquals: true, // only if this input is not shared across editor groups
|
||||
supportSideBySide: true // include side by side editor primary & secondary
|
||||
}))) {
|
||||
|
@ -691,11 +693,6 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
|
||||
//#region IEditorGroupView
|
||||
|
||||
private readonly _group: EditorGroup;
|
||||
get group(): EditorGroup {
|
||||
return this._group;
|
||||
}
|
||||
|
||||
get index(): number {
|
||||
return this._index;
|
||||
}
|
||||
|
@ -799,6 +796,10 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
return this._group.isActive(editor);
|
||||
}
|
||||
|
||||
contains(candidate: EditorInput, options?: { supportSideBySide?: boolean, strictEquals?: boolean }): boolean {
|
||||
return this._group.contains(candidate, options);
|
||||
}
|
||||
|
||||
getEditors(order: EditorsOrder, options?: { excludeSticky?: boolean }): EditorInput[] {
|
||||
return this._group.getEditors(order, options);
|
||||
}
|
||||
|
@ -1408,7 +1409,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
return false; // skip this group to avoid false assumptions about the editor being opened still
|
||||
}
|
||||
|
||||
const otherGroup = groupView.group;
|
||||
const otherGroup = groupView;
|
||||
if (otherGroup.contains(editor)) {
|
||||
return true; // exact editor still opened
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ export class NotebookEditor extends EditorPane {
|
|||
this._widgetDisposableStore.add(this._widget.value!.onDidFocus(() => this._onDidFocusWidget.fire()));
|
||||
|
||||
this._widgetDisposableStore.add(this._editorDropService.createEditorDropTarget(this._widget.value!.getDomNode(), {
|
||||
containsGroup: (group) => this.group?.id === group.group.id
|
||||
containsGroup: (group) => this.group?.id === group.id
|
||||
}));
|
||||
|
||||
mark(input.resource, 'editorLoaded');
|
||||
|
|
|
@ -164,7 +164,7 @@ export class WebviewEditor extends EditorPane {
|
|||
|
||||
// Webviews are not part of the normal editor dom, so we have to register our own drag and drop handler on them.
|
||||
this._webviewVisibleDisposables.add(this._editorDropService.createEditorDropTarget(input.webview.container, {
|
||||
containsGroup: (group) => this.group?.id === group.group.id
|
||||
containsGroup: (group) => this.group?.id === group.id
|
||||
}));
|
||||
|
||||
this._webviewVisibleDisposables.add(new WebviewWindowDragMonitor(() => this.webview));
|
||||
|
|
|
@ -531,6 +531,11 @@ export interface IEditorGroup {
|
|||
*/
|
||||
isActive(editor: IEditorInput): boolean;
|
||||
|
||||
/**
|
||||
* Find out if a certain editor is included in the group.
|
||||
*/
|
||||
contains(candidate: IEditorInput, options?: { supportSideBySide?: boolean, strictEquals?: boolean }): boolean;
|
||||
|
||||
/**
|
||||
* Move an editor from this group either within this group or to another group.
|
||||
*/
|
||||
|
|
|
@ -700,6 +700,7 @@ export class TestEditorGroupView implements IEditorGroupView {
|
|||
isPinned(_editor: IEditorInput): boolean { return false; }
|
||||
isSticky(_editor: IEditorInput): boolean { return false; }
|
||||
isActive(_editor: IEditorInput): boolean { return false; }
|
||||
contains(candidate: IEditorInput, options?: { supportSideBySide?: boolean | undefined; strictEquals?: boolean | undefined; }): boolean { return false; }
|
||||
moveEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IEditorOptions | ITextEditorOptions): void { }
|
||||
copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IEditorOptions | ITextEditorOptions): void { }
|
||||
async closeEditor(_editor?: IEditorInput, options?: ICloseEditorOptions): Promise<void> { }
|
||||
|
|
Loading…
Reference in a new issue