"Do you want to open it anyway?" in diff editor no-ops (fix #124222) (#126449)

* "Do you want to open it anyway?" in diff editor no-ops (fix #124222)

* update comment
This commit is contained in:
Benjamin Pasero 2021-06-17 15:32:07 +02:00 committed by GitHub
parent 9ce9551a8b
commit b8d2b90f44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,13 +41,21 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor {
}
private async openInternal(input: EditorInput, options: IEditorOptions | undefined): Promise<void> {
if (input instanceof FileEditorInput && this.group) {
if (input instanceof FileEditorInput && this.group && this.group.activeEditor) {
// We operate on the active editor here to support re-opening
// diff editors where `input` may just be one side of the
// diff editor.
// Since `openInternal` can only ever be selected from the
// active editor of the group, this is a safe assumption.
// (https://github.com/microsoft/vscode/issues/124222)
const editor = this.group.activeEditor;
// Enforce to open the input as text to enable our text based viewer
input.setForceOpenAsText();
// Try to let the user pick an override if there is one availabe
let overridenInput: ReturnedOverride | undefined = await this.editorOverrideService.resolveEditorOverride(input, { ...options, override: EditorOverride.PICK, }, this.group);
let overridenInput: ReturnedOverride | undefined = await this.editorOverrideService.resolveEditorOverride(editor, { ...options, override: EditorOverride.PICK, }, this.group);
if (overridenInput === OverrideStatus.NONE) {
overridenInput = undefined;
} else if (overridenInput === OverrideStatus.ABORT) {
@ -56,7 +64,7 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor {
// Replace the overrriden input, with the text based input
await this.editorService.replaceEditors([{
editor: input,
editor,
replacement: overridenInput?.editor ?? input,
options: {
...overridenInput?.options ?? options,