Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aux window - skip moving window to top after close editor #195721

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/vs/workbench/browser/parts/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ export interface IInternalEditorOpenOptions extends IInternalEditorTitleControlO
* When set to `true`, pass DOM focus into the tab control.
*/
readonly focusTabControl?: boolean;

/**
* When set to `true`, will not attempt to move the window to
* the top that the editor opens in.
*/
readonly preserveWindowOrder?: boolean;
}

export interface IInternalEditorCloseOptions extends IInternalEditorTitleControlOptions {
Expand Down
11 changes: 9 additions & 2 deletions src/vs/workbench/browser/parts/editor/editorGroupView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
let openEditorPromise: Promise<IEditorPane | undefined>;
if (context.active) {
openEditorPromise = (async () => {
const { pane, changed, cancelled, error } = await this.editorPane.openEditor(editor, options, { newInGroup: context.isNew });
const { pane, changed, cancelled, error } = await this.editorPane.openEditor(editor, options, internalOptions, { newInGroup: context.isNew });

// Return early if the operation was cancelled by another operation
if (cancelled) {
Expand Down Expand Up @@ -1415,7 +1415,14 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
ignoreError: internalOptions?.fromError
};

this.doOpenEditor(nextActiveEditor, options);
const internalEditorOpenOptions: IInternalEditorOpenOptions = {
// When closing an editor, we reveal the next one in the group.
// However, this can be a result of moving an editor to another
// window so we explicitly disable window reordering in this case.
preserveWindowOrder: true
};

this.doOpenEditor(nextActiveEditor, options, internalEditorOpenOptions);
}

// Otherwise we are empty, so clear from editor control and send event
Expand Down
21 changes: 11 additions & 10 deletions src/vs/workbench/browser/parts/editor/editorPanes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/la
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IEditorProgressService, LongRunningOperation } from 'vs/platform/progress/common/progress';
import { IEditorGroupView, DEFAULT_EDITOR_MIN_DIMENSIONS, DEFAULT_EDITOR_MAX_DIMENSIONS } from 'vs/workbench/browser/parts/editor/editor';
import { IEditorGroupView, DEFAULT_EDITOR_MIN_DIMENSIONS, DEFAULT_EDITOR_MAX_DIMENSIONS, IInternalEditorOpenOptions } from 'vs/workbench/browser/parts/editor/editor';
import { assertIsDefined } from 'vs/base/common/types';
import { IWorkspaceTrustManagementService } from 'vs/platform/workspace/common/workspaceTrust';
import { ErrorPlaceholderEditor, IErrorEditorPlaceholderOptions, WorkspaceTrustRequiredPlaceholderEditor } from 'vs/workbench/browser/parts/editor/editorPlaceholder';
Expand Down Expand Up @@ -126,7 +126,7 @@ export class EditorPanes extends Disposable {
}
}

async openEditor(editor: EditorInput, options: IEditorOptions | undefined, context: IEditorOpenContext = Object.create(null)): Promise<IOpenEditorResult> {
async openEditor(editor: EditorInput, options: IEditorOptions | undefined, internalOptions: IInternalEditorOpenOptions | undefined, context: IEditorOpenContext = Object.create(null)): Promise<IOpenEditorResult> {
try {

// Assert the `EditorInputCapabilities.AuxWindowUnsupported` condition
Expand All @@ -138,12 +138,12 @@ export class EditorPanes extends Disposable {
return this.groupView.closeEditor(editor);
}
})
], { forceMessage: true, forceSeverity: Severity.Warning }), editor, options, context);
], { forceMessage: true, forceSeverity: Severity.Warning }), editor, options, internalOptions, context);
}

// Open editor normally
else {
return await this.doOpenEditor(this.getEditorPaneDescriptor(editor), editor, options, context);
return await this.doOpenEditor(this.getEditorPaneDescriptor(editor), editor, options, internalOptions, context);
}
} catch (error) {

Expand All @@ -159,11 +159,11 @@ export class EditorPanes extends Disposable {
// For that reason we have place holder editors that can convey a
// message with actions the user can click on.

return this.doShowError(error, editor, options, context);
return this.doShowError(error, editor, options, internalOptions, context);
}
}

private async doShowError(error: Error, editor: EditorInput, options?: IEditorOptions, context?: IEditorOpenContext): Promise<IOpenEditorResult> {
private async doShowError(error: Error, editor: EditorInput, options: IEditorOptions | undefined, internalOptions: IInternalEditorOpenOptions | undefined, context?: IEditorOpenContext): Promise<IOpenEditorResult> {

// Always log the error to figure out what is going on
this.logService.error(error);
Expand All @@ -186,7 +186,7 @@ export class EditorPanes extends Disposable {
}

return {
...(await this.doOpenEditor(ErrorPlaceholderEditor.DESCRIPTOR, editor, editorPlaceholderOptions, context)),
...(await this.doOpenEditor(ErrorPlaceholderEditor.DESCRIPTOR, editor, editorPlaceholderOptions, internalOptions, context)),
error
};
}
Expand Down Expand Up @@ -258,7 +258,7 @@ export class EditorPanes extends Disposable {
return errorHandled;
}

private async doOpenEditor(descriptor: IEditorPaneDescriptor, editor: EditorInput, options: IEditorOptions | undefined, context: IEditorOpenContext = Object.create(null)): Promise<IOpenEditorResult> {
private async doOpenEditor(descriptor: IEditorPaneDescriptor, editor: EditorInput, options: IEditorOptions | undefined, internalOptions: IInternalEditorOpenOptions | undefined, context: IEditorOpenContext = Object.create(null)): Promise<IOpenEditorResult> {

// Editor pane
const pane = this.doShowEditorPane(descriptor);
Expand All @@ -270,12 +270,13 @@ export class EditorPanes extends Disposable {
const { changed, cancelled } = await this.doSetInput(pane, editor, options, context);

// Make sure to pass focus to the pane or otherwise
// make sure that the pane window is visible.
// make sure that the pane window is visible unless
// this has been explicitly disabled.
if (!cancelled) {
const focus = !options || !options.preserveFocus;
if (focus && this.shouldRestoreFocus(activeElement)) {
pane.focus();
} else {
} else if (!internalOptions?.preserveWindowOrder) {
const paneWindow = getWindow(pane.getContainer());
if (paneWindow !== getActiveWindow()) {
this.hostService.moveTop(paneWindow);
Expand Down