提交 58583a7b 编写于 作者: B Benjamin Pasero

fix #79633

上级 8108fc5e
......@@ -82,15 +82,26 @@ export interface IResourceInput extends IBaseResourceInput {
export enum EditorActivation {
/**
* Activate the editor after it opened.
* Activate the editor after it opened. This will automatically restore
* the editor if it is minimized.
*/
ACTIVATE,
/**
* Only restore the editor if it is minimized but do not activate it.
*
* Note: will only work in combination with the `preserveFocus: true` option.
* Otherwise, if focus moves into the editor, it will activate and restore
* automatically.
*/
RESTORE,
/**
* Preserve the current active editor.
*
* Note: will only work in combination with the
* `preserveFocus: true` option.
* Note: will only work in combination with the `preserveFocus: true` option.
* Otherwise, if focus moves into the editor, it will activate and restore
* automatically.
*/
PRESERVE
}
......@@ -107,7 +118,8 @@ export interface IEditorOptions {
/**
* This option is only relevant if an editor is opened into a group that is not active
* already and allows to control if the inactive group should become active or not.
* already and allows to control if the inactive group should become active, restored
* or preserved.
*
* By default, the editor group will become active unless `preserveFocus` or `inactive`
* is specified.
......
......@@ -119,7 +119,9 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
preserveFocus: options.preserveFocus,
pinned: options.pinned,
selection: options.selection,
activation: options.preserveFocus ? EditorActivation.PRESERVE : undefined // preserve pre 1.38 behaviour to not make group active when preserveFocus: true
// preserve pre 1.38 behaviour to not make group active when preserveFocus: true
// but make sure to restore the editor to fix https://github.com/microsoft/vscode/issues/79633
activation: options.preserveFocus ? EditorActivation.RESTORE : undefined
};
const input: IResourceInput = {
......
......@@ -838,9 +838,13 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
if (options && options.activation === EditorActivation.ACTIVATE) {
// Respect option to force activate an editor group.
activateGroup = true;
} else if (options && options.activation === EditorActivation.RESTORE) {
// Respect option to force restore an editor group.
restoreGroup = true;
} else if (options && options.activation === EditorActivation.PRESERVE) {
// Respect option to preserve active editor group.
activateGroup = false;
restoreGroup = false;
} else if (openEditorOptions.active) {
// Finally, we only activate/restore an editor which is
// opening as active editor.
......
......@@ -722,7 +722,8 @@ export class EditorOptions implements IEditorOptions {
/**
* This option is only relevant if an editor is opened into a group that is not active
* already and allows to control if the inactive group should become active or not.
* already and allows to control if the inactive group should become active, restored
* or preserved.
*
* By default, the editor group will become active unless `preserveFocus` or `inactive`
* is specified.
......
......@@ -150,7 +150,9 @@ export class WebviewEditorService implements IWebviewEditorService {
this._editorService.openEditor(webviewInput, {
pinned: true,
preserveFocus: showOptions.preserveFocus,
activation: showOptions.preserveFocus ? EditorActivation.PRESERVE : undefined // preserve pre 1.38 behaviour to not make group active when preserveFocus: true
// preserve pre 1.38 behaviour to not make group active when preserveFocus: true
// but make sure to restore the editor to fix https://github.com/microsoft/vscode/issues/79633
activation: showOptions.preserveFocus ? EditorActivation.RESTORE : undefined
}, showOptions.group);
return webviewInput;
}
......@@ -163,7 +165,9 @@ export class WebviewEditorService implements IWebviewEditorService {
if (webview.group === group.id) {
this._editorService.openEditor(webview, {
preserveFocus,
activation: preserveFocus ? EditorActivation.PRESERVE : undefined // preserve pre 1.38 behaviour to not make group active when preserveFocus: true
// preserve pre 1.38 behaviour to not make group active when preserveFocus: true
// but make sure to restore the editor to fix https://github.com/microsoft/vscode/issues/79633
activation: preserveFocus ? EditorActivation.RESTORE : undefined
}, webview.group);
} else {
const groupView = this._editorGroupService.getGroup(webview.group!);
......
......@@ -12,7 +12,7 @@ import { workbenchInstantiationService, TestStorageService } from 'vs/workbench/
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
import { EditorService, DelegatingEditorService } from 'vs/workbench/services/editor/browser/editorService';
import { IEditorGroup, IEditorGroupsService, GroupDirection } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorGroup, IEditorGroupsService, GroupDirection, GroupsArrangement } from 'vs/workbench/services/editor/common/editorGroupsService';
import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
......@@ -408,7 +408,7 @@ suite('EditorService', () => {
assert.equal(editor!.group, part.groups[1]);
});
test('pasero editor group activation', async () => {
test('editor group activation', async () => {
const partInstantiator = workbenchInstantiationService();
const part = partInstantiator.createInstance(EditorPart);
......@@ -443,6 +443,10 @@ suite('EditorService', () => {
editor = await service.openEditor(input2, { pinned: true, activation: EditorActivation.ACTIVATE }, sideGroup);
assert.equal(part.activeGroup, sideGroup);
part.arrangeGroups(GroupsArrangement.MINIMIZE_OTHERS);
editor = await service.openEditor(input1, { pinned: true, preserveFocus: true, activation: EditorActivation.RESTORE }, rootGroup);
assert.equal(part.activeGroup, sideGroup);
});
test('active editor change / visible editor change events', async function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册