提交 d37a76dc 编写于 作者: J Johannes Rieken

allow empty string as valid document content, fixes #6526

上级 b6f0eee2
......@@ -294,6 +294,23 @@ suite('workspace-namespace', () => {
});
});
test('registerTextDocumentContentProvider, empty doc', function () {
let registration = workspace.registerTextDocumentContentProvider('foo', {
provideTextDocumentContent(uri) {
return '';
}
});
const uri = Uri.parse('foo:doc/empty');
return workspace.openTextDocument(uri).then(doc => {
assert.equal(doc.getText(), '');
assert.equal(doc.uri.toString(), uri.toString());
registration.dispose();
});
});
test('registerTextDocumentContentProvider, change event', function () {
let callCount = 0;
......
......@@ -631,7 +631,7 @@ export class MainThreadDocuments {
this._resourceContentProvider[handle] = ResourceEditorInput.registerResourceContentProvider(scheme, {
provideTextContent: (uri: URI): TPromise<EditorCommon.IModel> => {
return this._proxy.$provideTextDocumentContent(handle, uri).then(value => {
if (value) {
if (typeof value === 'string') {
this._virtualDocumentSet[uri.toString()] = true;
const firstLineText = value.substr(0, 1 + value.search(/\r?\n/));
const mode = this._modeService.getOrCreateModeByFilenameOrFirstLine(uri.fsPath, firstLineText);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册