some api test love

This commit is contained in:
Johannes Rieken 2017-05-04 16:22:19 +02:00
parent b7bb7dd96c
commit 127b909c10
2 changed files with 155 additions and 160 deletions

View file

@ -8,7 +8,7 @@ import * as vscode from 'vscode';
suite('Configuration tests', () => {
test('Default configurations', function () {
test('configurations, language defaults', function () {
const defaultLanguageSettings = vscode.workspace.getConfiguration().get('[abcLang]');
assert.deepEqual(defaultLanguageSettings, {
@ -17,4 +17,29 @@ suite('Configuration tests', () => {
});
});
});
test('configuration, defaults', () => {
const config = vscode.workspace.getConfiguration('farboo');
assert.ok(config.has('config0'));
assert.equal(config.get('config0'), true);
assert.equal(config.get('config4'), '');
assert.equal(config['config0'], true);
assert.equal(config['config4'], '');
assert.throws(() => (<any>config)['config4'] = 'valuevalue');
assert.ok(config.has('nested.config1'));
assert.equal(config.get('nested.config1'), 42);
assert.ok(config.has('nested.config2'));
assert.equal(config.get('nested.config2'), 'Das Pferd frisst kein Reis.');
});
test('configuration, name vs property', () => {
const config = vscode.workspace.getConfiguration('farboo');
assert.ok(config.has('get'));
assert.equal(config.get('get'), 'get-prop');
assert.deepEqual(config['get'], config.get);
assert.throws(() => config['get'] = <any>'get-prop');
});
});

View file

@ -6,7 +6,7 @@
'use strict';
import * as assert from 'assert';
import { workspace, TextDocument, window, Position, Uri, EventEmitter, WorkspaceEdit, Disposable, EndOfLine } from 'vscode';
import * as vscode from 'vscode';
import { createRandomFile, deleteFile, cleanUp, pathEquals } from './utils';
import { join, basename } from 'path';
import * as fs from 'fs';
@ -15,59 +15,29 @@ suite('workspace-namespace', () => {
teardown(cleanUp);
test('configuration, defaults', () => {
const config = workspace.getConfiguration('farboo');
assert.ok(config.has('config0'));
assert.equal(config.get('config0'), true);
assert.equal(config.get('config4'), '');
assert.equal(config['config0'], true);
assert.equal(config['config4'], '');
assert.throws(() => (<any>config)['config4'] = 'valuevalue');
assert.ok(config.has('nested.config1'));
assert.equal(config.get('nested.config1'), 42);
assert.ok(config.has('nested.config2'));
assert.equal(config.get('nested.config2'), 'Das Pferd frisst kein Reis.');
});
test('configuration, name vs property', () => {
const config = workspace.getConfiguration('farboo');
assert.ok(config.has('get'));
assert.equal(config.get('get'), 'get-prop');
assert.deepEqual(config['get'], config.get);
assert.throws(() => config['get'] = <any>'get-prop');
});
// test('configuration, getConfig/value', () => {
// const value = workspace.getConfiguration('farboo.config0');
// assert.equal(Object.keys(value).length, 3);
// });
test('textDocuments', () => {
assert.ok(Array.isArray(workspace.textDocuments));
assert.throws(() => (<any>workspace).textDocuments = null);
assert.ok(Array.isArray(vscode.workspace.textDocuments));
assert.throws(() => (<any>vscode.workspace).textDocuments = null);
});
test('rootPath', () => {
if (workspace.rootPath) {
assert.ok(pathEquals(workspace.rootPath, join(__dirname, '../testWorkspace')));
if (vscode.workspace.rootPath) {
assert.ok(pathEquals(vscode.workspace.rootPath, join(__dirname, '../testWorkspace')));
}
assert.throws(() => workspace.rootPath = 'farboo');
assert.throws(() => vscode.workspace.rootPath = 'farboo');
});
test('openTextDocument', () => {
let len = workspace.textDocuments.length;
return workspace.openTextDocument(join(workspace.rootPath || '', './simple.txt')).then(doc => {
let len = vscode.workspace.textDocuments.length;
return vscode.workspace.openTextDocument(join(vscode.workspace.rootPath || '', './simple.txt')).then(doc => {
assert.ok(doc);
assert.equal(workspace.textDocuments.length, len + 1);
assert.equal(vscode.workspace.textDocuments.length, len + 1);
});
});
test('openTextDocument, illegal path', () => {
return workspace.openTextDocument('funkydonky.txt').then(doc => {
return vscode.workspace.openTextDocument('funkydonky.txt').then(doc => {
throw new Error('missing error');
}, err => {
// good!
@ -75,28 +45,28 @@ suite('workspace-namespace', () => {
});
test('openTextDocument, untitled is dirty', function () {
return workspace.openTextDocument(Uri.parse('untitled:' + join(workspace.rootPath || '', './newfile.txt'))).then(doc => {
return vscode.workspace.openTextDocument(vscode.Uri.parse('untitled:' + join(vscode.workspace.rootPath || '', './newfile.txt'))).then(doc => {
assert.equal(doc.uri.scheme, 'untitled');
assert.ok(doc.isDirty);
});
});
test('openTextDocument, untitled with host', function () {
const uri = Uri.parse('untitled://localhost/c%24/Users/jrieken/code/samples/foobar.txt');
return workspace.openTextDocument(uri).then(doc => {
const uri = vscode.Uri.parse('untitled://localhost/c%24/Users/jrieken/code/samples/foobar.txt');
return vscode.workspace.openTextDocument(uri).then(doc => {
assert.equal(doc.uri.scheme, 'untitled');
});
});
test('openTextDocument, untitled without path', function () {
return workspace.openTextDocument().then(doc => {
return vscode.workspace.openTextDocument().then(doc => {
assert.equal(doc.uri.scheme, 'untitled');
assert.ok(doc.isDirty);
});
});
test('openTextDocument, untitled without path but language ID', function () {
return workspace.openTextDocument({ language: 'xml' }).then(doc => {
return vscode.workspace.openTextDocument({ language: 'xml' }).then(doc => {
assert.equal(doc.uri.scheme, 'untitled');
assert.equal(doc.languageId, 'xml');
assert.ok(doc.isDirty);
@ -104,7 +74,7 @@ suite('workspace-namespace', () => {
});
test('openTextDocument, untitled without path but language ID and content', function () {
return workspace.openTextDocument({ language: 'html', content: '<h1>Hello world!</h1>' }).then(doc => {
return vscode.workspace.openTextDocument({ language: 'html', content: '<h1>Hello world!</h1>' }).then(doc => {
assert.equal(doc.uri.scheme, 'untitled');
assert.equal(doc.languageId, 'html');
assert.ok(doc.isDirty);
@ -113,16 +83,16 @@ suite('workspace-namespace', () => {
});
test('openTextDocument, untitled closes on save', function (done) {
const path = join(workspace.rootPath || '', './newfile.txt');
const path = join(vscode.workspace.rootPath || '', './newfile.txt');
return workspace.openTextDocument(Uri.parse('untitled:' + path)).then(doc => {
return vscode.workspace.openTextDocument(vscode.Uri.parse('untitled:' + path)).then(doc => {
assert.equal(doc.uri.scheme, 'untitled');
assert.ok(doc.isDirty);
let closed: TextDocument;
let d0 = workspace.onDidCloseTextDocument(e => closed = e);
let closed: vscode.TextDocument;
let d0 = vscode.workspace.onDidCloseTextDocument(e => closed = e);
return window.showTextDocument(doc).then(() => {
return vscode.window.showTextDocument(doc).then(() => {
return doc.save().then(() => {
assert.ok(closed === doc);
assert.ok(!doc.isDirty);
@ -130,7 +100,7 @@ suite('workspace-namespace', () => {
d0.dispose();
return deleteFile(Uri.file(join(workspace.rootPath || '', './newfile.txt'))).then(() => done(null));
return deleteFile(vscode.Uri.file(join(vscode.workspace.rootPath || '', './newfile.txt'))).then(() => done(null));
});
});
@ -139,22 +109,22 @@ suite('workspace-namespace', () => {
test('openTextDocument, uri scheme/auth/path', function () {
let registration = workspace.registerTextDocumentContentProvider('sc', {
let registration = vscode.workspace.registerTextDocumentContentProvider('sc', {
provideTextDocumentContent() {
return 'SC';
}
});
return Promise.all([
workspace.openTextDocument(Uri.parse('sc://auth')).then(doc => {
vscode.workspace.openTextDocument(vscode.Uri.parse('sc://auth')).then(doc => {
assert.equal(doc.uri.authority, 'auth');
assert.equal(doc.uri.path, '');
}),
workspace.openTextDocument(Uri.parse('sc:///path')).then(doc => {
vscode.workspace.openTextDocument(vscode.Uri.parse('sc:///path')).then(doc => {
assert.equal(doc.uri.authority, '');
assert.equal(doc.uri.path, '/path');
}),
workspace.openTextDocument(Uri.parse('sc://auth/path')).then(doc => {
vscode.workspace.openTextDocument(vscode.Uri.parse('sc://auth/path')).then(doc => {
assert.equal(doc.uri.authority, 'auth');
assert.equal(doc.uri.path, '/path');
})
@ -165,110 +135,110 @@ suite('workspace-namespace', () => {
test('eol, read', () => {
const a = createRandomFile('foo\nbar\nbar').then(file => {
return workspace.openTextDocument(file).then(doc => {
assert.equal(doc.eol, EndOfLine.LF);
return vscode.workspace.openTextDocument(file).then(doc => {
assert.equal(doc.eol, vscode.EndOfLine.LF);
});
});
const b = createRandomFile('foo\nbar\nbar\r\nbaz').then(file => {
return workspace.openTextDocument(file).then(doc => {
assert.equal(doc.eol, EndOfLine.LF);
return vscode.workspace.openTextDocument(file).then(doc => {
assert.equal(doc.eol, vscode.EndOfLine.LF);
});
});
const c = createRandomFile('foo\r\nbar\r\nbar').then(file => {
return workspace.openTextDocument(file).then(doc => {
assert.equal(doc.eol, EndOfLine.CRLF);
return vscode.workspace.openTextDocument(file).then(doc => {
assert.equal(doc.eol, vscode.EndOfLine.CRLF);
});
});
return Promise.all([a, b, c]);
});
// test('eol, change via editor', () => {
// return createRandomFile('foo\nbar\nbar').then(file => {
// return workspace.openTextDocument(file).then(doc => {
// assert.equal(doc.eol, EndOfLine.LF);
// return window.showTextDocument(doc).then(editor => {
// return editor.edit(builder => builder.setEndOfLine(EndOfLine.CRLF));
test('eol, change via editor', () => {
return createRandomFile('foo\nbar\nbar').then(file => {
return vscode.workspace.openTextDocument(file).then(doc => {
assert.equal(doc.eol, vscode.EndOfLine.LF);
return vscode.window.showTextDocument(doc).then(editor => {
return editor.edit(builder => builder.setEndOfLine(vscode.EndOfLine.CRLF));
// }).then(value => {
// assert.ok(value);
// assert.ok(doc.isDirty);
// assert.equal(doc.eol, EndOfLine.CRLF);
// });
// });
// });
// });
}).then(value => {
assert.ok(value);
assert.ok(doc.isDirty);
assert.equal(doc.eol, vscode.EndOfLine.CRLF);
});
});
});
});
// test('eol, change via applyEdit', () => {
// return createRandomFile('foo\nbar\nbar').then(file => {
// return workspace.openTextDocument(file).then(doc => {
// assert.equal(doc.eol, EndOfLine.LF);
test('eol, change via applyEdit', () => {
return createRandomFile('foo\nbar\nbar').then(file => {
return vscode.workspace.openTextDocument(file).then(doc => {
assert.equal(doc.eol, vscode.EndOfLine.LF);
// const edit = new WorkspaceEdit();
// edit.set(file, [TextEdit.setEndOfLine(EndOfLine.CRLF)]);
// return workspace.applyEdit(edit).then(value => {
// assert.ok(value);
// assert.ok(doc.isDirty);
// assert.equal(doc.eol, EndOfLine.CRLF);
// });
// });
// });
// });
const edit = new vscode.WorkspaceEdit();
edit.set(file, [vscode.TextEdit.setEndOfLine(vscode.EndOfLine.CRLF)]);
return vscode.workspace.applyEdit(edit).then(value => {
assert.ok(value);
assert.ok(doc.isDirty);
assert.equal(doc.eol, vscode.EndOfLine.CRLF);
});
});
});
});
// test('eol, change via onWillSave', () => {
test('eol, change via onWillSave', () => {
// let called = false;
// let sub = workspace.onWillSaveTextDocument(e => {
// called = true;
// e.waitUntil(Promise.resolve([TextEdit.setEndOfLine(EndOfLine.LF)]));
// });
let called = false;
let sub = vscode.workspace.onWillSaveTextDocument(e => {
called = true;
e.waitUntil(Promise.resolve([vscode.TextEdit.setEndOfLine(vscode.EndOfLine.LF)]));
});
// return createRandomFile('foo\r\nbar\r\nbar').then(file => {
// return workspace.openTextDocument(file).then(doc => {
// assert.equal(doc.eol, EndOfLine.CRLF);
// const edit = new WorkspaceEdit();
// edit.set(file, [TextEdit.insert(new Position(0, 0), '-changes-')]);
return createRandomFile('foo\r\nbar\r\nbar').then(file => {
return vscode.workspace.openTextDocument(file).then(doc => {
assert.equal(doc.eol, vscode.EndOfLine.CRLF);
const edit = new vscode.WorkspaceEdit();
edit.set(file, [vscode.TextEdit.insert(new vscode.Position(0, 0), '-changes-')]);
// return workspace.applyEdit(edit).then(success => {
// assert.ok(success);
// return doc.save();
return vscode.workspace.applyEdit(edit).then(success => {
assert.ok(success);
return doc.save();
// }).then(success => {
// assert.ok(success);
// assert.ok(called);
// assert.ok(!doc.isDirty);
// assert.equal(doc.eol, EndOfLine.LF);
// sub.dispose();
// });
// });
// });
// });
}).then(success => {
assert.ok(success);
assert.ok(called);
assert.ok(!doc.isDirty);
assert.equal(doc.eol, vscode.EndOfLine.LF);
sub.dispose();
});
});
});
});
test('events: onDidOpenTextDocument, onDidChangeTextDocument, onDidSaveTextDocument', () => {
return createRandomFile().then(file => {
let disposables: Disposable[] = [];
let disposables: vscode.Disposable[] = [];
let onDidOpenTextDocument = false;
disposables.push(workspace.onDidOpenTextDocument(e => {
disposables.push(vscode.workspace.onDidOpenTextDocument(e => {
assert.ok(pathEquals(e.uri.fsPath, file.fsPath));
onDidOpenTextDocument = true;
}));
let onDidChangeTextDocument = false;
disposables.push(workspace.onDidChangeTextDocument(e => {
disposables.push(vscode.workspace.onDidChangeTextDocument(e => {
assert.ok(pathEquals(e.document.uri.fsPath, file.fsPath));
onDidChangeTextDocument = true;
}));
let onDidSaveTextDocument = false;
disposables.push(workspace.onDidSaveTextDocument(e => {
disposables.push(vscode.workspace.onDidSaveTextDocument(e => {
assert.ok(pathEquals(e.uri.fsPath, file.fsPath));
onDidSaveTextDocument = true;
}));
return workspace.openTextDocument(file).then(doc => {
return window.showTextDocument(doc).then((editor) => {
return vscode.workspace.openTextDocument(file).then(doc => {
return vscode.window.showTextDocument(doc).then((editor) => {
return editor.edit((builder) => {
builder.insert(new Position(0, 0), 'Hello World');
builder.insert(new vscode.Position(0, 0), 'Hello World');
}).then(applied => {
return doc.save().then(saved => {
assert.ok(onDidOpenTextDocument);
@ -292,14 +262,14 @@ suite('workspace-namespace', () => {
test('registerTextDocumentContentProvider, simple', function () {
let registration = workspace.registerTextDocumentContentProvider('foo', {
let registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
provideTextDocumentContent(uri) {
return uri.toString();
}
});
const uri = Uri.parse('foo://testing/virtual.js');
return workspace.openTextDocument(uri).then(doc => {
const uri = vscode.Uri.parse('foo://testing/virtual.js');
return vscode.workspace.openTextDocument(uri).then(doc => {
assert.equal(doc.getText(), uri.toString());
assert.equal(doc.isDirty, false);
assert.equal(doc.uri.toString(), uri.toString());
@ -311,15 +281,15 @@ suite('workspace-namespace', () => {
// built-in
assert.throws(function () {
workspace.registerTextDocumentContentProvider('untitled', { provideTextDocumentContent() { return null; } });
vscode.workspace.registerTextDocumentContentProvider('untitled', { provideTextDocumentContent() { return null; } });
});
// built-in
assert.throws(function () {
workspace.registerTextDocumentContentProvider('file', { provideTextDocumentContent() { return null; } });
vscode.workspace.registerTextDocumentContentProvider('file', { provideTextDocumentContent() { return null; } });
});
// missing scheme
return workspace.openTextDocument(Uri.parse('notThere://foo/far/boo/bar')).then(() => {
return vscode.workspace.openTextDocument(vscode.Uri.parse('notThere://foo/far/boo/bar')).then(() => {
assert.ok(false, 'expected failure');
}, err => {
// expected
@ -329,14 +299,14 @@ suite('workspace-namespace', () => {
test('registerTextDocumentContentProvider, multiple', function () {
// duplicate registration
let registration1 = workspace.registerTextDocumentContentProvider('foo', {
let registration1 = vscode.workspace.registerTextDocumentContentProvider('foo', {
provideTextDocumentContent(uri) {
if (uri.authority === 'foo') {
return '1';
}
}
});
let registration2 = workspace.registerTextDocumentContentProvider('foo', {
let registration2 = vscode.workspace.registerTextDocumentContentProvider('foo', {
provideTextDocumentContent(uri) {
if (uri.authority === 'bar') {
return '2';
@ -345,8 +315,8 @@ suite('workspace-namespace', () => {
});
return Promise.all([
workspace.openTextDocument(Uri.parse('foo://foo/bla')).then(doc => { assert.equal(doc.getText(), '1'); }),
workspace.openTextDocument(Uri.parse('foo://bar/bla')).then(doc => { assert.equal(doc.getText(), '2'); })
vscode.workspace.openTextDocument(vscode.Uri.parse('foo://foo/bla')).then(doc => { assert.equal(doc.getText(), '1'); }),
vscode.workspace.openTextDocument(vscode.Uri.parse('foo://bar/bla')).then(doc => { assert.equal(doc.getText(), '2'); })
]).then(() => {
registration1.dispose();
registration2.dispose();
@ -356,18 +326,18 @@ suite('workspace-namespace', () => {
test('registerTextDocumentContentProvider, evil provider', function () {
// duplicate registration
let registration1 = workspace.registerTextDocumentContentProvider('foo', {
let registration1 = vscode.workspace.registerTextDocumentContentProvider('foo', {
provideTextDocumentContent(uri) {
return '1';
}
});
let registration2 = workspace.registerTextDocumentContentProvider('foo', {
let registration2 = vscode.workspace.registerTextDocumentContentProvider('foo', {
provideTextDocumentContent(uri): string {
throw new Error('fail');
}
});
return workspace.openTextDocument(Uri.parse('foo://foo/bla')).then(doc => {
return vscode.workspace.openTextDocument(vscode.Uri.parse('foo://foo/bla')).then(doc => {
assert.equal(doc.getText(), '1');
registration1.dispose();
registration2.dispose();
@ -376,12 +346,12 @@ suite('workspace-namespace', () => {
test('registerTextDocumentContentProvider, invalid text', function () {
let registration = workspace.registerTextDocumentContentProvider('foo', {
let registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
provideTextDocumentContent(uri) {
return <any>123;
}
});
return workspace.openTextDocument(Uri.parse('foo://auth/path')).then(() => {
return vscode.workspace.openTextDocument(vscode.Uri.parse('foo://auth/path')).then(() => {
assert.ok(false, 'expected failure');
}, err => {
// expected
@ -391,14 +361,14 @@ suite('workspace-namespace', () => {
test('registerTextDocumentContentProvider, show virtual document', function () {
let registration = workspace.registerTextDocumentContentProvider('foo', {
let registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
provideTextDocumentContent(uri) {
return 'I am virtual';
}
});
return workspace.openTextDocument(Uri.parse('foo://something/path')).then(doc => {
return window.showTextDocument(doc).then(editor => {
return vscode.workspace.openTextDocument(vscode.Uri.parse('foo://something/path')).then(doc => {
return vscode.window.showTextDocument(doc).then(editor => {
assert.ok(editor.document === doc);
assert.equal(editor.document.getText(), 'I am virtual');
@ -410,19 +380,19 @@ suite('workspace-namespace', () => {
test('registerTextDocumentContentProvider, open/open document', function () {
let callCount = 0;
let registration = workspace.registerTextDocumentContentProvider('foo', {
let registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
provideTextDocumentContent(uri) {
callCount += 1;
return 'I am virtual';
}
});
const uri = Uri.parse('foo://testing/path');
const uri = vscode.Uri.parse('foo://testing/path');
return Promise.all([workspace.openTextDocument(uri), workspace.openTextDocument(uri)]).then(docs => {
return Promise.all([vscode.workspace.openTextDocument(uri), vscode.workspace.openTextDocument(uri)]).then(docs => {
let [first, second] = docs;
assert.ok(first === second);
assert.ok(workspace.textDocuments.some(doc => doc.uri.toString() === uri.toString()));
assert.ok(vscode.workspace.textDocuments.some(doc => doc.uri.toString() === uri.toString()));
assert.equal(callCount, 1);
registration.dispose();
});
@ -430,15 +400,15 @@ suite('workspace-namespace', () => {
test('registerTextDocumentContentProvider, empty doc', function () {
let registration = workspace.registerTextDocumentContentProvider('foo', {
let registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
provideTextDocumentContent(uri) {
return '';
}
});
const uri = Uri.parse('foo:doc/empty');
const uri = vscode.Uri.parse('foo:doc/empty');
return workspace.openTextDocument(uri).then(doc => {
return vscode.workspace.openTextDocument(uri).then(doc => {
assert.equal(doc.getText(), '');
assert.equal(doc.uri.toString(), uri.toString());
registration.dispose();
@ -448,25 +418,25 @@ suite('workspace-namespace', () => {
test('registerTextDocumentContentProvider, change event', function () {
let callCount = 0;
let emitter = new EventEmitter<Uri>();
let emitter = new vscode.EventEmitter<vscode.Uri>();
let registration = workspace.registerTextDocumentContentProvider('foo', {
let registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
onDidChange: emitter.event,
provideTextDocumentContent(uri) {
return 'call' + (callCount++);
}
});
const uri = Uri.parse('foo://testing/path3');
const uri = vscode.Uri.parse('foo://testing/path3');
return workspace.openTextDocument(uri).then(doc => {
return vscode.workspace.openTextDocument(uri).then(doc => {
assert.equal(callCount, 1);
assert.equal(doc.getText(), 'call0');
return new Promise((resolve, reject) => {
let subscription = workspace.onDidChangeTextDocument(event => {
let subscription = vscode.workspace.onDidChangeTextDocument(event => {
subscription.dispose();
assert.ok(event.document === doc);
assert.equal(event.document.getText(), 'call1');
@ -481,9 +451,9 @@ suite('workspace-namespace', () => {
});
test('findFiles', () => {
return workspace.findFiles('*.js').then((res) => {
return vscode.workspace.findFiles('*.js').then((res) => {
assert.equal(res.length, 1);
assert.equal(basename(workspace.asRelativePath(res[0])), 'far.js');
assert.equal(basename(vscode.workspace.asRelativePath(res[0])), 'far.js');
});
});
@ -494,17 +464,17 @@ suite('workspace-namespace', () => {
// const token = source.token; // just to get an instance first
// source.cancel();
// return workspace.findFiles('*.js', null, 100, token).then((res) => {
// return vscode.workspace.findFiles('*.js', null, 100, token).then((res) => {
// assert.equal(res, void 0);
// });
// });
test('applyEdit', () => {
return workspace.openTextDocument(Uri.parse('untitled:' + join(workspace.rootPath || '', './new2.txt'))).then(doc => {
let edit = new WorkspaceEdit();
edit.insert(doc.uri, new Position(0, 0), new Array(1000).join('Hello World'));
return workspace.applyEdit(edit);
return vscode.workspace.openTextDocument(vscode.Uri.parse('untitled:' + join(vscode.workspace.rootPath || '', './new2.txt'))).then(doc => {
let edit = new vscode.WorkspaceEdit();
edit.insert(doc.uri, new vscode.Position(0, 0), new Array(1000).join('Hello World'));
return vscode.workspace.applyEdit(edit);
});
});
});