提交 6153a487 编写于 作者: B Benjamin Pasero

'revealIfOpened' flag should start at active editor (fixes #9265)

上级 be298bfd
......@@ -136,7 +136,7 @@ export class DefinitionAction extends EditorAction {
resource: uri,
options: {
selection: range,
revealIfOpened: !sideBySide
revealIfVisible: !sideBySide
}
}, sideBySide).then(editor => {
return <editorCommon.IEditor> editor.getControl();
......
......@@ -152,10 +152,9 @@ export interface IEditorOptions {
forceOpen?: boolean;
/**
* Will reveal the editor if it is already opened in any editor group.
* This prevents duplicates of the same editor input showing up.
* Will reveal the editor if it is already opened and visible in any of the opened editor groups.
*/
revealIfOpened?: boolean;
revealIfVisible?: boolean;
/**
* An editor that is pinned remains in the editor stack even when another editor is being opened.
......
......@@ -1146,10 +1146,8 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
return Position.LEFT; // can only be LEFT
}
// Respect option to reveal an editor if it is already opened
if (options && options.revealIfOpened) {
// First check over active and visible editors from left to right
// Respect option to reveal an editor if it is already visible
if (options && options.revealIfVisible) {
const editorsToCheck: BaseEditor[] = [];
if (activeEditor) { editorsToCheck.push(activeEditor); }
visibleEditors.forEach(e => { if (e !== activeEditor) { editorsToCheck.push(e); }});
......@@ -1159,17 +1157,6 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
return editorToCheck.position;
}
}
// Then check over active and visible groups from left to right
const groupsToCheck: EditorGroup[] = [];
if (this.stacks.activeGroup) { groupsToCheck.push(this.stacks.activeGroup); }
this.stacks.groups.forEach(g => { if (g !== this.stacks.activeGroup) { groupsToCheck.push(g); }});
for (let i = 0; i < groupsToCheck.length; i++) {
const groupToCheck = groupsToCheck[i];
if (groupToCheck.contains(input)) {
return this.stacks.positionOfGroup(groupToCheck);
}
}
}
// Position is unknown: pick last active or LEFT
......
......@@ -430,7 +430,7 @@ export class EditorOptions implements IEditorOptions {
let options = new EditorOptions();
options.preserveFocus = settings.preserveFocus;
options.forceOpen = settings.forceOpen;
options.revealIfOpened = settings.revealIfOpened;
options.revealIfVisible = settings.revealIfVisible;
options.pinned = settings.pinned;
options.index = settings.index;
options.inactive = settings.inactive;
......@@ -444,7 +444,7 @@ export class EditorOptions implements IEditorOptions {
public mixin(other: EditorOptions): void {
this.preserveFocus = other.preserveFocus;
this.forceOpen = other.forceOpen;
this.revealIfOpened = other.revealIfOpened;
this.revealIfVisible = other.revealIfVisible;
this.pinned = other.pinned;
this.index = other.index;
}
......@@ -463,10 +463,9 @@ export class EditorOptions implements IEditorOptions {
public forceOpen: boolean;
/**
* Will reveal the editor if it is already opened in any editor group.
* This prevents duplicates of the same editor input showing up.
* Will reveal the editor if it is already opened and visible in any of the opened editor groups.
*/
public revealIfOpened: boolean;
public revealIfVisible: boolean;
/**
* An editor that is pinned remains in the editor stack even when another editor is being opened.
......@@ -494,13 +493,13 @@ export class TextEditorOptions extends EditorOptions {
protected startColumn: number;
protected endLineNumber: number;
protected endColumn: number;
private editorViewState: IEditorViewState;
public static from(input: IResourceInput): TextEditorOptions {
let options: TextEditorOptions = null;
if (input && input.options) {
if (input.options.selection || input.options.forceOpen || input.options.revealIfOpened || input.options.preserveFocus || input.options.pinned || input.options.inactive || typeof input.options.index === 'number') {
if (input.options.selection || input.options.forceOpen || input.options.revealIfVisible || input.options.preserveFocus || input.options.pinned || input.options.inactive || typeof input.options.index === 'number') {
options = new TextEditorOptions();
}
......@@ -513,8 +512,8 @@ export class TextEditorOptions extends EditorOptions {
options.forceOpen = true;
}
if (input.options.revealIfOpened) {
options.revealIfOpened = true;
if (input.options.revealIfVisible) {
options.revealIfVisible = true;
}
if (input.options.preserveFocus) {
......@@ -544,7 +543,7 @@ export class TextEditorOptions extends EditorOptions {
let options = new TextEditorOptions();
options.preserveFocus = settings.preserveFocus;
options.forceOpen = settings.forceOpen;
options.revealIfOpened = settings.revealIfOpened;
options.revealIfVisible = settings.revealIfVisible;
options.pinned = settings.pinned;
options.index = settings.index;
......@@ -654,7 +653,7 @@ export class TextDiffEditorOptions extends TextEditorOptions {
options.preserveFocus = settings.preserveFocus;
options.forceOpen = settings.forceOpen;
options.revealIfOpened = settings.revealIfOpened;
options.revealIfVisible = settings.revealIfVisible;
options.pinned = settings.pinned;
options.index = settings.index;
......
......@@ -266,7 +266,7 @@ export class ExplorerView extends CollapsibleViewletView {
if (lastActiveFileResource && root && root.find(lastActiveFileResource)) {
let editorInput = this.instantiationService.createInstance(FileEditorInput, lastActiveFileResource, void 0, void 0);
this.editorService.openEditor(editorInput, { revealIfOpened: true }).done(null, errors.onUnexpectedError);
this.editorService.openEditor(editorInput, { revealIfVisible: true }).done(null, errors.onUnexpectedError);
return refreshPromise;
}
......@@ -284,7 +284,7 @@ export class ExplorerView extends CollapsibleViewletView {
if (stat && !stat.isDirectory) {
let editorInput = this.instantiationService.createInstance(FileEditorInput, stat.resource, stat.mime, void 0);
this.editorService.openEditor(editorInput, { preserveFocus, revealIfOpened: true }).done(null, errors.onUnexpectedError);
this.editorService.openEditor(editorInput, { preserveFocus, revealIfVisible: true }).done(null, errors.onUnexpectedError);
}
}
......
......@@ -313,9 +313,9 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
let options = state.options;
if (options) {
options.revealIfOpened = true;
options.revealIfVisible = true;
} else {
options = { revealIfOpened: true };
options = { revealIfVisible: true };
}
this.blockStackChanges = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册