improve revert logic for untitled (also dispose untitled input after save)

This commit is contained in:
Benjamin Pasero
2016-06-06 16:20:12 +02:00
parent 483c63bc0c
commit dcd7c87af5
12 changed files with 61 additions and 38 deletions

View File

@@ -64,7 +64,7 @@ suite('workspace-namespace', () => {
});
});
test('openTextDocument, untitled closes on save', function () {
test('openTextDocument, untitled closes on save', function (done) {
const path = join(workspace.rootPath, './newfile.txt');
return workspace.openTextDocument(Uri.parse('untitled:' + path)).then(doc => {
@@ -74,15 +74,18 @@ suite('workspace-namespace', () => {
let closed: TextDocument;
let d0 = workspace.onDidCloseTextDocument(e => closed = e);
return doc.save().then(() => {
assert.ok(closed === doc);
assert.ok(!doc.isDirty);
assert.ok(fs.existsSync(path));
return window.showTextDocument(doc).then(() => {
return doc.save().then(() => {
assert.ok(closed === doc);
assert.ok(!doc.isDirty);
assert.ok(fs.existsSync(path));
d0.dispose();
d0.dispose();
return deleteFile(Uri.file(join(workspace.rootPath, './newfile.txt')));
return deleteFile(Uri.file(join(workspace.rootPath, './newfile.txt'))).then(() => done(null));
});
});
});
});