Clearing WorkingFilesModel should only add file types to recently closed files

Fixes #5997
This commit is contained in:
Daniel Imms 2016-05-13 19:35:42 -07:00
parent 9cff38ac88
commit cd1d4d8f55
2 changed files with 19 additions and 4 deletions

View file

@ -355,14 +355,14 @@ export class WorkingFilesModel implements IWorkingFilesModel {
// Put the active entry on the top of the stack
let input = this.editorService.getActiveEditorInput();
let resource: uri = getUntitledOrFileResource(input);
let activeResource: uri = getUntitledOrFileResource(input);
let activeEntry: WorkingFileEntry;
if (resource) {
activeEntry = this.findEntry(resource);
if (activeResource && activeResource.scheme === 'file') {
activeEntry = this.findEntry(activeResource);
}
this.recentlyClosedEntries = this.recentlyClosedEntries.concat(resources.filter(e => {
return !activeEntry || e.resource.path !== activeEntry.resource.path;
return (!activeEntry || e.resource.path !== activeEntry.resource.path) && e.resource.scheme === 'file';
}));
if (activeEntry) {

View file

@ -116,6 +116,21 @@ suite('Files - WorkingFilesModel', () => {
assert.equal(model.popLastClosedEntry(), null);
});
test("Clearing the model only adds files to the closed entries", function() {
let model = baseInstantiationService.createInstance(WorkingFilesModel);
model.addEntry(URI.create('untitled', null, '/foo'));
assert.equal(model.popLastClosedEntry(), null);
model.clear();
assert.equal(model.popLastClosedEntry(), null);
model.addEntry(URI.create('file', null, '/foo'));
model.addEntry(URI.create('untitled', null, '/bar'));
model.clear();
assert.ok(model.popLastClosedEntry().isFile);
assert.equal(model.popLastClosedEntry(), null);
});
test("Reopening multiple files will open the editor in the previously opened file", function() {
let model = baseInstantiationService.createInstance(WorkingFilesModel);