grid - maintain ViewColumn API compatibility (webview)

This commit is contained in:
Benjamin Pasero
2018-05-20 13:13:59 +02:00
parent dd5afa5bcc
commit abe0207f0a
5 changed files with 100 additions and 68 deletions

View File

@@ -119,7 +119,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
options: editorOptions
};
return this._editorService.openEditor(input, this._findEditorGroup(options.position)).then(editor => {
return this._editorService.openEditor(input, findEditorGroup(this._editorGroupService, options.position)).then(editor => {
if (!editor) {
return undefined;
}
@@ -134,31 +134,11 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
return this._editorService.openEditor({
resource: model.uri,
options: { preserveFocus: false }
}, this._findEditorGroup(position)).then(() => { return; });
}, findEditorGroup(this._editorGroupService, position)).then(() => { return; });
}
return undefined;
}
private _findEditorGroup(position?: EditorPosition): GroupIdentifier {
if (typeof position !== 'number') {
return ACTIVE_GROUP; // prefer active group when position is undefined
}
const groups = this._editorGroupService.groups;
let candidate = groups[position];
if (candidate) {
return candidate.id; // found direct match
}
let firstGroup = groups[0];
if (groups.length === 1 && firstGroup.count === 0) {
return firstGroup.id; // first editor should always open in first group
}
return SIDE_GROUP; // open to the side if group not found
}
$tryHideEditor(id: string): TPromise<void> {
let mainThreadEditor = this._documentsAndEditors.getEditor(id);
if (mainThreadEditor) {
@@ -260,3 +240,23 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
return TPromise.as(diffEditor.getLineChanges());
}
}
export function findEditorGroup(editorGroupService: INextEditorGroupsService, position?: EditorPosition): GroupIdentifier {
if (typeof position !== 'number') {
return ACTIVE_GROUP; // prefer active group when position is undefined
}
const groups = editorGroupService.groups;
let candidate = groups[position];
if (candidate) {
return candidate.id; // found direct match
}
let firstGroup = groups[0];
if (groups.length === 1 && firstGroup.count === 0) {
return firstGroup.id; // first editor should always open in first group
}
return SIDE_GROUP; // open to the side if group not found
}