提交 a18110ad 编写于 作者: B Benjamin Pasero

editors - bring back close() to inputs

上级 99a07407
......@@ -530,11 +530,11 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
editorsToClose.push(editor.master, editor.details);
}
// Dispose the editor when it is no longer open in any group including diff editors
// Forward close to editor input for handling within
editorsToClose.forEach(editorToClose => {
if (!this.accessor.groups.some(groupView => groupView.group.contains(editorToClose, true /* include side by side editor master & details */))) {
editorToClose.dispose();
}
const openedInOtherGroups = this.accessor.groups.some(groupView => groupView.group.contains(editorToClose, true /* include side by side editor master & details */));
editorToClose.close(this._group.id, openedInOtherGroups);
});
/* __GDPR__
......
......@@ -581,6 +581,21 @@ export abstract class EditorInput extends Disposable implements IEditorInput {
return undefined;
}
/**
* Called when this input was closed in a group. The second parameter
* is a hint wether the editor is still opened in other groups. This
* may include normal editors as well as side-by-side or diff editors.
*
* Subclasses can override what should happen. By default, an editor
* input will dispose when it is closed.
*/
close(group: GroupIdentifier, openedInOtherGroups: boolean): void {
// TODO@ben revisit this behaviour, should just dispose by default after adoption
if (!openedInOtherGroups) {
this.dispose();
}
}
/**
* Subclasses can set this to false if it does not make sense to split the editor input.
*/
......
......@@ -303,6 +303,12 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements
return undefined;
}
close(group: GroupIdentifier, openedInOtherGroups: boolean): void {
if (!openedInOtherGroups) {
this.dispose(); // Only dispose if not opened anymore because all file inputs are shared
}
}
matches(otherInput: unknown): boolean {
if (super.matches(otherInput) === true) {
return true;
......
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IEncodingSupport, EncodingMode, Verbosity, IModeSupport } from 'vs/workbench/common/editor';
import { IEncodingSupport, EncodingMode, Verbosity, IModeSupport, GroupIdentifier } from 'vs/workbench/common/editor';
import { AbstractTextResourceEditorInput } from 'vs/workbench/common/editor/textResourceEditorInput';
import { IUntitledTextEditorModel } from 'vs/workbench/services/untitled/common/untitledTextEditorModel';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
......@@ -121,6 +121,12 @@ export class UntitledTextEditorInput extends AbstractTextResourceEditorInput imp
return this.modelResolve;
}
close(group: GroupIdentifier, openedInOtherGroups: boolean): void {
if (!openedInOtherGroups) {
this.dispose(); // Only dispose if not opened anymore because all untitled inputs are shared
}
}
matches(otherInput: unknown): boolean {
if (super.matches(otherInput) === true) {
return true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册