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

fix #79633

上级 8108fc5e
...@@ -82,15 +82,26 @@ export interface IResourceInput extends IBaseResourceInput { ...@@ -82,15 +82,26 @@ export interface IResourceInput extends IBaseResourceInput {
export enum EditorActivation { 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, 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. * Preserve the current active editor.
* *
* Note: will only work in combination with the * Note: will only work in combination with the `preserveFocus: true` option.
* `preserveFocus: true` option. * Otherwise, if focus moves into the editor, it will activate and restore
* automatically.
*/ */
PRESERVE PRESERVE
} }
...@@ -107,7 +118,8 @@ export interface IEditorOptions { ...@@ -107,7 +118,8 @@ export interface IEditorOptions {
/** /**
* This option is only relevant if an editor is opened into a group that is not active * 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` * By default, the editor group will become active unless `preserveFocus` or `inactive`
* is specified. * is specified.
......
...@@ -119,7 +119,9 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape { ...@@ -119,7 +119,9 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
preserveFocus: options.preserveFocus, preserveFocus: options.preserveFocus,
pinned: options.pinned, pinned: options.pinned,
selection: options.selection, 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 = { const input: IResourceInput = {
......
...@@ -838,9 +838,13 @@ export class EditorGroupView extends Themable implements IEditorGroupView { ...@@ -838,9 +838,13 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
if (options && options.activation === EditorActivation.ACTIVATE) { if (options && options.activation === EditorActivation.ACTIVATE) {
// Respect option to force activate an editor group. // Respect option to force activate an editor group.
activateGroup = true; 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) { } else if (options && options.activation === EditorActivation.PRESERVE) {
// Respect option to preserve active editor group. // Respect option to preserve active editor group.
activateGroup = false; activateGroup = false;
restoreGroup = false;
} else if (openEditorOptions.active) { } else if (openEditorOptions.active) {
// Finally, we only activate/restore an editor which is // Finally, we only activate/restore an editor which is
// opening as active editor. // opening as active editor.
......
...@@ -722,7 +722,8 @@ export class EditorOptions implements IEditorOptions { ...@@ -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 * 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` * By default, the editor group will become active unless `preserveFocus` or `inactive`
* is specified. * is specified.
......
...@@ -150,7 +150,9 @@ export class WebviewEditorService implements IWebviewEditorService { ...@@ -150,7 +150,9 @@ export class WebviewEditorService implements IWebviewEditorService {
this._editorService.openEditor(webviewInput, { this._editorService.openEditor(webviewInput, {
pinned: true, pinned: true,
preserveFocus: showOptions.preserveFocus, 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); }, showOptions.group);
return webviewInput; return webviewInput;
} }
...@@ -163,7 +165,9 @@ export class WebviewEditorService implements IWebviewEditorService { ...@@ -163,7 +165,9 @@ export class WebviewEditorService implements IWebviewEditorService {
if (webview.group === group.id) { if (webview.group === group.id) {
this._editorService.openEditor(webview, { this._editorService.openEditor(webview, {
preserveFocus, 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); }, webview.group);
} else { } else {
const groupView = this._editorGroupService.getGroup(webview.group!); const groupView = this._editorGroupService.getGroup(webview.group!);
......
...@@ -12,7 +12,7 @@ import { workbenchInstantiationService, TestStorageService } from 'vs/workbench/ ...@@ -12,7 +12,7 @@ import { workbenchInstantiationService, TestStorageService } from 'vs/workbench/
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput'; import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService'; import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
import { EditorService, DelegatingEditorService } from 'vs/workbench/services/editor/browser/editorService'; 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 { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService'; import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
...@@ -408,7 +408,7 @@ suite('EditorService', () => { ...@@ -408,7 +408,7 @@ suite('EditorService', () => {
assert.equal(editor!.group, part.groups[1]); assert.equal(editor!.group, part.groups[1]);
}); });
test('pasero editor group activation', async () => { test('editor group activation', async () => {
const partInstantiator = workbenchInstantiationService(); const partInstantiator = workbenchInstantiationService();
const part = partInstantiator.createInstance(EditorPart); const part = partInstantiator.createInstance(EditorPart);
...@@ -443,6 +443,10 @@ suite('EditorService', () => { ...@@ -443,6 +443,10 @@ suite('EditorService', () => {
editor = await service.openEditor(input2, { pinned: true, activation: EditorActivation.ACTIVATE }, sideGroup); editor = await service.openEditor(input2, { pinned: true, activation: EditorActivation.ACTIVATE }, sideGroup);
assert.equal(part.activeGroup, 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 () { 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.
先完成此消息的编辑!
想要评论请 注册