Closing a dirty split editor (existing OR untitled) should not affect the initial editor (fixes #8983)
This commit is contained in:
parent
665b278948
commit
b59f466b01
3 changed files with 9 additions and 5 deletions
|
@ -647,7 +647,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
|
|||
}
|
||||
|
||||
private doHandleDirty(identifier: EditorIdentifier): TPromise<boolean /* veto */> {
|
||||
if (!identifier || !identifier.editor || !identifier.editor.isDirty()) {
|
||||
if (!identifier || !identifier.editor || !identifier.editor.isDirty() || this.stacks.count(identifier.editor) > 1 /* allow to close a dirty editor if it is opened in another group */) {
|
||||
return TPromise.as(false); // no veto
|
||||
}
|
||||
|
||||
|
|
|
@ -1095,11 +1095,13 @@ export class EditorStacksModel implements IEditorStacksModel {
|
|||
public isOpen(resource: URI): boolean;
|
||||
public isOpen(editor: EditorInput): boolean;
|
||||
public isOpen(arg1: any): boolean {
|
||||
if (arg1 instanceof EditorInput) {
|
||||
return this._groups.some(g => g.indexOf(arg1) >= 0);
|
||||
}
|
||||
return this._groups.some(group => group.contains(arg1));
|
||||
}
|
||||
|
||||
return this._groups.some(group => group.contains(<URI>arg1));
|
||||
public count(resource: URI): number;
|
||||
public count(editor: EditorInput): number;
|
||||
public count(arg1: any): number {
|
||||
return this._groups.filter(group => group.contains(arg1)).length;
|
||||
}
|
||||
|
||||
private onShutdown(): void {
|
||||
|
|
|
@ -1481,6 +1481,7 @@ suite('Editor Stacks Model', () => {
|
|||
|
||||
assert.ok(model.isOpen(input1Resource));
|
||||
assert.ok(group1.contains(input1Resource));
|
||||
assert.equal(model.count(input1Resource), 1);
|
||||
|
||||
group2.openEditor(input1);
|
||||
group1.closeEditor(input1);
|
||||
|
@ -1488,6 +1489,7 @@ suite('Editor Stacks Model', () => {
|
|||
assert.ok(model.isOpen(input1Resource));
|
||||
assert.ok(!group1.contains(input1Resource));
|
||||
assert.ok(group2.contains(input1Resource));
|
||||
assert.equal(model.count(input1Resource), 1);
|
||||
|
||||
const input1ResourceClone = URI.file('/hello/world.txt');
|
||||
const input1Clone = input(void 0, false, input1ResourceClone);
|
||||
|
|
Loading…
Reference in a new issue