本文整理汇总了TypeScript中vs/editor/common/model/textModel.createTextBufferFactory函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createTextBufferFactory函数的具体用法?TypeScript createTextBufferFactory怎么用?TypeScript createTextBufferFactory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createTextBufferFactory函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('untitled file', function (done: () => void) {
service.backupResource(untitledFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).createSnapshot(false)).then(() => {
assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'untitled')).length, 1);
assert.equal(fs.existsSync(untitledBackupPath), true);
assert.equal(fs.readFileSync(untitledBackupPath), `${untitledFile.toString()}\ntest`);
done();
});
});
示例2: createTextBufferFactory
return service.getWorkspaceFileBackups().then(textFiles => {
assert.deepEqual(textFiles.map(f => f.fsPath), [fooFile.fsPath]);
return service.backupResource(barFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).createSnapshot(false)).then(() => {
return service.getWorkspaceFileBackups().then(textFiles => {
assert.deepEqual(textFiles.map(f => f.fsPath), [fooFile.fsPath, barFile.fsPath]);
});
});
});
示例3: test
test('should restore the original contents (untitled file)', () => {
const contents = 'test\nand more stuff';
service.backupResource(untitledFile, createTextBufferFactory(contents).create(DefaultEndOfLine.LF).createSnapshot(false)).then(() => {
service.resolveBackupContent(service.toBackupResource(untitledFile)).then(factory => {
assert.equal(contents, snapshotToString(factory!.create(platform.isWindows ? DefaultEndOfLine.CRLF : DefaultEndOfLine.LF).createSnapshot(true)));
});
});
});
示例4: test
test('BaseTextEditorModel', async () => {
let modelService = stubModelService(instantiationService);
let m = new MyTextEditorModel(modelService, modeService);
const model = await m.load() as MyTextEditorModel;
assert(model === m);
model.createTextEditorModel(createTextBufferFactory('foo'), null!, 'text/plain');
assert.strictEqual(m.isResolved(), true);
m.dispose();
});
示例5: testResolveBackup
async function testResolveBackup(resource: URI, contents: string, meta?: IBackupTestMetaData, expectedMeta?: IBackupTestMetaData | null) {
if (typeof expectedMeta === 'undefined') {
expectedMeta = meta;
}
await service.backupResource(resource, createTextBufferFactory(contents).create(DefaultEndOfLine.LF).createSnapshot(false), 1, meta);
assert.ok(await service.loadBackupResource(resource));
const backup = await service.resolveBackupContent<IBackupTestMetaData>(service.toBackupResource(resource));
assert.equal(contents, snapshotToString(backup.value.create(platform.isWindows ? DefaultEndOfLine.CRLF : DefaultEndOfLine.LF).createSnapshot(true)));
if (expectedMeta) {
assert.equal(backup.meta!.etag, expectedMeta.etag);
assert.equal(backup.meta!.size, expectedMeta.size);
assert.equal(backup.meta!.mtime, expectedMeta.mtime);
assert.equal(backup.meta!.orphaned, expectedMeta.orphaned);
} else {
assert.ok(!backup.meta);
}
}