mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
This reverts commit 5d44b6a6a7.
This commit is contained in:
@@ -86,7 +86,7 @@ class MyResourceInput extends ResourceEditorInput { }
|
||||
|
||||
suite('Workbench base editor', () => {
|
||||
|
||||
test('BaseEditor API', async () => {
|
||||
test('BaseEditor API', function () {
|
||||
let e = new MyEditor(NullTelemetryService);
|
||||
let input = new MyOtherInput();
|
||||
let options = new EditorOptions();
|
||||
@@ -94,24 +94,25 @@ suite('Workbench base editor', () => {
|
||||
assert(!e.isVisible());
|
||||
assert(!e.input);
|
||||
assert(!e.options);
|
||||
return e.setInput(input, options, CancellationToken.None).then(() => {
|
||||
assert.strictEqual(input, e.input);
|
||||
assert.strictEqual(options, e.options);
|
||||
|
||||
await e.setInput(input, options, CancellationToken.None);
|
||||
assert.strictEqual(input, e.input);
|
||||
assert.strictEqual(options, e.options);
|
||||
const group = new TestEditorGroup(1);
|
||||
e.setVisible(true, group);
|
||||
assert(e.isVisible());
|
||||
assert.equal(e.group, group);
|
||||
input.onDispose(() => {
|
||||
assert(false);
|
||||
const group = new TestEditorGroup(1);
|
||||
e.setVisible(true, group);
|
||||
assert(e.isVisible());
|
||||
assert.equal(e.group, group);
|
||||
input.onDispose(() => {
|
||||
assert(false);
|
||||
});
|
||||
e.dispose();
|
||||
e.clearInput();
|
||||
e.setVisible(false, group);
|
||||
assert(!e.isVisible());
|
||||
assert(!e.input);
|
||||
assert(!e.options);
|
||||
assert(!e.getControl());
|
||||
});
|
||||
e.dispose();
|
||||
e.clearInput();
|
||||
e.setVisible(false, group);
|
||||
assert(!e.isVisible());
|
||||
assert(!e.input);
|
||||
assert(!e.options);
|
||||
assert(!e.getControl());
|
||||
});
|
||||
|
||||
test('EditorDescriptor', () => {
|
||||
@@ -153,10 +154,10 @@ suite('Workbench base editor', () => {
|
||||
|
||||
let inst = new TestInstantiationService();
|
||||
|
||||
const editor = EditorRegistry.getEditor(inst.createInstance(MyResourceInput, 'fake', '', URI.file('/fake'), undefined))!.instantiate(inst);
|
||||
const editor = EditorRegistry.getEditor(inst.createInstance(MyResourceInput, 'fake', '', URI.file('/fake')))!.instantiate(inst);
|
||||
assert.strictEqual(editor.getId(), 'myEditor');
|
||||
|
||||
const otherEditor = EditorRegistry.getEditor(inst.createInstance(ResourceEditorInput, 'fake', '', URI.file('/fake'), undefined))!.instantiate(inst);
|
||||
const otherEditor = EditorRegistry.getEditor(inst.createInstance(ResourceEditorInput, 'fake', '', URI.file('/fake')))!.instantiate(inst);
|
||||
assert.strictEqual(otherEditor.getId(), 'myOtherEditor');
|
||||
|
||||
(<any>EditorRegistry).setEditors(oldEditors);
|
||||
@@ -172,7 +173,7 @@ suite('Workbench base editor', () => {
|
||||
|
||||
let inst = new TestInstantiationService();
|
||||
|
||||
const editor = EditorRegistry.getEditor(inst.createInstance(MyResourceInput, 'fake', '', URI.file('/fake'), undefined))!.instantiate(inst);
|
||||
const editor = EditorRegistry.getEditor(inst.createInstance(MyResourceInput, 'fake', '', URI.file('/fake')))!.instantiate(inst);
|
||||
assert.strictEqual('myOtherEditor', editor.getId());
|
||||
|
||||
(<any>EditorRegistry).setEditors(oldEditors);
|
||||
|
||||
@@ -35,7 +35,7 @@ suite('Workbench editor model', () => {
|
||||
accessor = instantiationService.createInstance(ServiceAccessor);
|
||||
});
|
||||
|
||||
test('TextDiffEditorModel', async () => {
|
||||
test('TextDiffEditorModel', () => {
|
||||
const dispose = accessor.textModelResolverService.registerTextModelContentProvider('test', {
|
||||
provideTextContent: function (resource: URI): Promise<ITextModel> {
|
||||
if (resource.scheme === 'test') {
|
||||
@@ -48,26 +48,27 @@ suite('Workbench editor model', () => {
|
||||
}
|
||||
});
|
||||
|
||||
let input = instantiationService.createInstance(ResourceEditorInput, 'name', 'description', URI.from({ scheme: 'test', authority: null!, path: 'thePath' }), undefined);
|
||||
let otherInput = instantiationService.createInstance(ResourceEditorInput, 'name2', 'description', URI.from({ scheme: 'test', authority: null!, path: 'thePath' }), undefined);
|
||||
let input = instantiationService.createInstance(ResourceEditorInput, 'name', 'description', URI.from({ scheme: 'test', authority: null!, path: 'thePath' }));
|
||||
let otherInput = instantiationService.createInstance(ResourceEditorInput, 'name2', 'description', URI.from({ scheme: 'test', authority: null!, path: 'thePath' }));
|
||||
let diffInput = new DiffEditorInput('name', 'description', input, otherInput);
|
||||
|
||||
let model = await diffInput.resolve() as TextDiffEditorModel;
|
||||
return diffInput.resolve().then((model: any) => {
|
||||
assert(model);
|
||||
assert(model instanceof TextDiffEditorModel);
|
||||
|
||||
assert(model);
|
||||
assert(model instanceof TextDiffEditorModel);
|
||||
let diffEditorModel = model.textDiffEditorModel;
|
||||
assert(diffEditorModel.original);
|
||||
assert(diffEditorModel.modified);
|
||||
|
||||
let diffEditorModel = model.textDiffEditorModel!;
|
||||
assert(diffEditorModel.original);
|
||||
assert(diffEditorModel.modified);
|
||||
return diffInput.resolve().then((model: any) => {
|
||||
assert(model.isResolved());
|
||||
|
||||
model = await diffInput.resolve() as TextDiffEditorModel;
|
||||
assert(model.isResolved());
|
||||
assert(diffEditorModel !== model.textDiffEditorModel);
|
||||
diffInput.dispose();
|
||||
assert(!model.textDiffEditorModel);
|
||||
|
||||
assert(diffEditorModel !== model.textDiffEditorModel);
|
||||
diffInput.dispose();
|
||||
assert(!model.textDiffEditorModel);
|
||||
|
||||
dispose.dispose();
|
||||
dispose.dispose();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -111,17 +111,27 @@ class TestFileEditorInput extends EditorInput implements IFileEditorInput {
|
||||
}
|
||||
getTypeId() { return 'testFileEditorInputForGroups'; }
|
||||
resolve(): Promise<IEditorModel> { return Promise.resolve(null!); }
|
||||
setEncoding(encoding: string) { }
|
||||
getEncoding(): string { return null!; }
|
||||
setPreferredEncoding(encoding: string) { }
|
||||
getResource(): URI { return this.resource; }
|
||||
setForceOpenAsBinary(): void { }
|
||||
setMode(mode: string) { }
|
||||
setPreferredMode(mode: string) { }
|
||||
|
||||
matches(other: TestFileEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestFileEditorInput;
|
||||
}
|
||||
|
||||
setEncoding(encoding: string) {
|
||||
}
|
||||
|
||||
getEncoding(): string {
|
||||
return null!;
|
||||
}
|
||||
|
||||
setPreferredEncoding(encoding: string) {
|
||||
}
|
||||
|
||||
getResource(): URI {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
setForceOpenAsBinary(): void {
|
||||
}
|
||||
}
|
||||
|
||||
function input(id = String(index++), nonSerializable?: boolean, resource?: URI): EditorInput {
|
||||
|
||||
@@ -21,8 +21,8 @@ import { TestTextResourcePropertiesService } from 'vs/workbench/test/workbenchTe
|
||||
|
||||
class MyEditorModel extends EditorModel { }
|
||||
class MyTextEditorModel extends BaseTextEditorModel {
|
||||
public createTextEditorModel(value: ITextBufferFactory, resource?: URI, preferredMode?: string) {
|
||||
return super.createTextEditorModel(value, resource, preferredMode);
|
||||
public createTextEditorModel(value: ITextBufferFactory, resource?: URI, modeId?: string) {
|
||||
return super.createTextEditorModel(value, resource, modeId);
|
||||
}
|
||||
|
||||
isReadonly(): boolean {
|
||||
@@ -40,7 +40,7 @@ suite('Workbench editor model', () => {
|
||||
modeService = instantiationService.stub(IModeService, ModeServiceImpl);
|
||||
});
|
||||
|
||||
test('EditorModel', async () => {
|
||||
test('EditorModel', () => {
|
||||
let counter = 0;
|
||||
|
||||
let m = new MyEditorModel();
|
||||
@@ -50,23 +50,25 @@ suite('Workbench editor model', () => {
|
||||
counter++;
|
||||
});
|
||||
|
||||
const model = await m.load();
|
||||
assert(model === m);
|
||||
assert.strictEqual(m.isResolved(), true);
|
||||
m.dispose();
|
||||
assert.equal(counter, 1);
|
||||
return m.load().then(model => {
|
||||
assert(model === m);
|
||||
assert.strictEqual(m.isResolved(), true);
|
||||
m.dispose();
|
||||
assert.equal(counter, 1);
|
||||
});
|
||||
});
|
||||
|
||||
test('BaseTextEditorModel', async () => {
|
||||
test('BaseTextEditorModel', () => {
|
||||
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();
|
||||
return m.load().then((model: MyTextEditorModel) => {
|
||||
assert(model === m);
|
||||
model.createTextEditorModel(createTextBufferFactory('foo'), null!, 'text/plain');
|
||||
assert.strictEqual(m.isResolved(), true);
|
||||
}).then(() => {
|
||||
m.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
function stubModelService(instantiationService: TestInstantiationService): IModelService {
|
||||
|
||||
@@ -12,16 +12,17 @@ import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestSe
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { snapshotToString } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { ModesRegistry, PLAINTEXT_MODE_ID } from 'vs/editor/common/modes/modesRegistry';
|
||||
|
||||
class ServiceAccessor {
|
||||
constructor(
|
||||
@IModelService public modelService: IModelService,
|
||||
@IModeService public modeService: IModeService
|
||||
) { }
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
suite('Workbench resource editor input', () => {
|
||||
|
||||
let instantiationService: IInstantiationService;
|
||||
let accessor: ServiceAccessor;
|
||||
|
||||
@@ -30,33 +31,14 @@ suite('Workbench resource editor input', () => {
|
||||
accessor = instantiationService.createInstance(ServiceAccessor);
|
||||
});
|
||||
|
||||
test('basics', async () => {
|
||||
const resource = URI.from({ scheme: 'inmemory', authority: null!, path: 'thePath' });
|
||||
test('simple', () => {
|
||||
let resource = URI.from({ scheme: 'inmemory', authority: null!, path: 'thePath' });
|
||||
accessor.modelService.createModel('function test() {}', accessor.modeService.create('text'), resource);
|
||||
let input: ResourceEditorInput = instantiationService.createInstance(ResourceEditorInput, 'The Name', 'The Description', resource);
|
||||
|
||||
const input: ResourceEditorInput = instantiationService.createInstance(ResourceEditorInput, 'The Name', 'The Description', resource, undefined);
|
||||
|
||||
const model = await input.resolve();
|
||||
|
||||
assert.ok(model);
|
||||
assert.equal(snapshotToString(((model as ResourceEditorModel).createSnapshot()!)), 'function test() {}');
|
||||
});
|
||||
|
||||
test('custom mode', async () => {
|
||||
ModesRegistry.registerLanguage({
|
||||
id: 'resource-input-test',
|
||||
return input.resolve().then(model => {
|
||||
assert.ok(model);
|
||||
assert.equal(snapshotToString((model as ResourceEditorModel).createSnapshot()!), 'function test() {}');
|
||||
});
|
||||
|
||||
const resource = URI.from({ scheme: 'inmemory', authority: null!, path: 'thePath' });
|
||||
accessor.modelService.createModel('function test() {}', accessor.modeService.create('text'), resource);
|
||||
|
||||
const input: ResourceEditorInput = instantiationService.createInstance(ResourceEditorInput, 'The Name', 'The Description', resource, 'resource-input-test');
|
||||
|
||||
const model = await input.resolve();
|
||||
assert.ok(model);
|
||||
assert.equal(model.textEditorModel.getModeId(), 'resource-input-test');
|
||||
|
||||
input.setMode('text');
|
||||
assert.equal(model.textEditorModel.getModeId(), PLAINTEXT_MODE_ID);
|
||||
});
|
||||
});
|
||||
@@ -16,7 +16,6 @@ import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
|
||||
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { snapshotToString } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { ModesRegistry, PLAINTEXT_MODE_ID } from 'vs/editor/common/modes/modesRegistry';
|
||||
|
||||
export class TestUntitledEditorService extends UntitledEditorService {
|
||||
get(resource: URI) { return super.get(resource); }
|
||||
@@ -46,7 +45,7 @@ suite('Workbench untitled editors', () => {
|
||||
accessor.untitledEditorService.dispose();
|
||||
});
|
||||
|
||||
test('Untitled Editor Service', async (done) => {
|
||||
test('Untitled Editor Service', function (done) {
|
||||
const service = accessor.untitledEditorService;
|
||||
assert.equal(service.getAll().length, 0);
|
||||
|
||||
@@ -69,35 +68,36 @@ suite('Workbench untitled editors', () => {
|
||||
assert.equal(service.getAll().length, 1);
|
||||
|
||||
// dirty
|
||||
const model = await input2.resolve();
|
||||
input2.resolve().then(model => {
|
||||
assert.ok(!service.isDirty(input2.getResource()));
|
||||
|
||||
assert.ok(!service.isDirty(input2.getResource()));
|
||||
const listener = service.onDidChangeDirty(resource => {
|
||||
listener.dispose();
|
||||
|
||||
const listener = service.onDidChangeDirty(resource => {
|
||||
listener.dispose();
|
||||
assert.equal(resource.toString(), input2.getResource().toString());
|
||||
|
||||
assert.equal(resource.toString(), input2.getResource().toString());
|
||||
assert.ok(service.isDirty(input2.getResource()));
|
||||
assert.equal(service.getDirty()[0].toString(), input2.getResource().toString());
|
||||
assert.equal(service.getDirty([input2.getResource()])[0].toString(), input2.getResource().toString());
|
||||
assert.equal(service.getDirty([input1.getResource()]).length, 0);
|
||||
|
||||
assert.ok(service.isDirty(input2.getResource()));
|
||||
assert.equal(service.getDirty()[0].toString(), input2.getResource().toString());
|
||||
assert.equal(service.getDirty([input2.getResource()])[0].toString(), input2.getResource().toString());
|
||||
assert.equal(service.getDirty([input1.getResource()]).length, 0);
|
||||
service.revertAll();
|
||||
assert.equal(service.getAll().length, 0);
|
||||
assert.ok(!input2.isDirty());
|
||||
assert.ok(!model.isDirty());
|
||||
|
||||
service.revertAll();
|
||||
assert.equal(service.getAll().length, 0);
|
||||
assert.ok(!input2.isDirty());
|
||||
assert.ok(!model.isDirty());
|
||||
input2.dispose();
|
||||
|
||||
input2.dispose();
|
||||
assert.ok(!service.exists(input2.getResource()));
|
||||
|
||||
assert.ok(!service.exists(input2.getResource()));
|
||||
done();
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
model.textEditorModel.setValue('foo bar');
|
||||
model.textEditorModel.setValue('foo bar');
|
||||
}, err => done(err));
|
||||
});
|
||||
|
||||
test('Untitled with associated resource', () => {
|
||||
test('Untitled with associated resource', function () {
|
||||
const service = accessor.untitledEditorService;
|
||||
const file = URI.file(join('C:\\', '/foo/file.txt'));
|
||||
const untitled = service.createOrGet(file);
|
||||
@@ -107,49 +107,53 @@ suite('Workbench untitled editors', () => {
|
||||
untitled.dispose();
|
||||
});
|
||||
|
||||
test('Untitled no longer dirty when content gets empty', async () => {
|
||||
test('Untitled no longer dirty when content gets empty', function () {
|
||||
const service = accessor.untitledEditorService;
|
||||
const input = service.createOrGet();
|
||||
|
||||
// dirty
|
||||
const model = await input.resolve();
|
||||
model.textEditorModel.setValue('foo bar');
|
||||
assert.ok(model.isDirty());
|
||||
model.textEditorModel.setValue('');
|
||||
assert.ok(!model.isDirty());
|
||||
input.dispose();
|
||||
return input.resolve().then(model => {
|
||||
model.textEditorModel.setValue('foo bar');
|
||||
assert.ok(model.isDirty());
|
||||
|
||||
model.textEditorModel.setValue('');
|
||||
assert.ok(!model.isDirty());
|
||||
|
||||
input.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
test('Untitled via loadOrCreate', async () => {
|
||||
test('Untitled via loadOrCreate', function () {
|
||||
const service = accessor.untitledEditorService;
|
||||
service.loadOrCreate().then(model1 => {
|
||||
model1.textEditorModel!.setValue('foo bar');
|
||||
assert.ok(model1.isDirty());
|
||||
|
||||
const model1 = await service.loadOrCreate();
|
||||
model1.textEditorModel!.setValue('');
|
||||
assert.ok(!model1.isDirty());
|
||||
|
||||
model1.textEditorModel!.setValue('foo bar');
|
||||
assert.ok(model1.isDirty());
|
||||
return service.loadOrCreate({ initialValue: 'Hello World' }).then(model2 => {
|
||||
assert.equal(snapshotToString(model2.createSnapshot()!), 'Hello World');
|
||||
|
||||
model1.textEditorModel!.setValue('');
|
||||
assert.ok(!model1.isDirty());
|
||||
const input = service.createOrGet();
|
||||
|
||||
const model2 = await service.loadOrCreate({ initialValue: 'Hello World' });
|
||||
assert.equal(snapshotToString(model2.createSnapshot()!), 'Hello World');
|
||||
return service.loadOrCreate({ resource: input.getResource() }).then(model3 => {
|
||||
assert.equal(model3.getResource().toString(), input.getResource().toString());
|
||||
|
||||
const input = service.createOrGet();
|
||||
const file = URI.file(join('C:\\', '/foo/file44.txt'));
|
||||
return service.loadOrCreate({ resource: file }).then(model4 => {
|
||||
assert.ok(service.hasAssociatedFilePath(model4.getResource()));
|
||||
assert.ok(model4.isDirty());
|
||||
|
||||
const model3 = await service.loadOrCreate({ resource: input.getResource() });
|
||||
|
||||
assert.equal(model3.getResource().toString(), input.getResource().toString());
|
||||
|
||||
const file = URI.file(join('C:\\', '/foo/file44.txt'));
|
||||
const model4 = await service.loadOrCreate({ resource: file });
|
||||
assert.ok(service.hasAssociatedFilePath(model4.getResource()));
|
||||
assert.ok(model4.isDirty());
|
||||
|
||||
model1.dispose();
|
||||
model2.dispose();
|
||||
model3.dispose();
|
||||
model4.dispose();
|
||||
input.dispose();
|
||||
model1.dispose();
|
||||
model2.dispose();
|
||||
model3.dispose();
|
||||
model4.dispose();
|
||||
input.dispose();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('Untitled suggest name', function () {
|
||||
@@ -159,31 +163,24 @@ suite('Workbench untitled editors', () => {
|
||||
assert.ok(service.suggestFileName(input.getResource()));
|
||||
});
|
||||
|
||||
test('Untitled with associated path remains dirty when content gets empty', async () => {
|
||||
test('Untitled with associated path remains dirty when content gets empty', function () {
|
||||
const service = accessor.untitledEditorService;
|
||||
const file = URI.file(join('C:\\', '/foo/file.txt'));
|
||||
const input = service.createOrGet(file);
|
||||
|
||||
// dirty
|
||||
const model = await input.resolve();
|
||||
model.textEditorModel.setValue('foo bar');
|
||||
assert.ok(model.isDirty());
|
||||
model.textEditorModel.setValue('');
|
||||
assert.ok(model.isDirty());
|
||||
input.dispose();
|
||||
return input.resolve().then(model => {
|
||||
model.textEditorModel.setValue('foo bar');
|
||||
assert.ok(model.isDirty());
|
||||
|
||||
model.textEditorModel.setValue('');
|
||||
assert.ok(model.isDirty());
|
||||
|
||||
input.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
test('Untitled with initial content is dirty', async () => {
|
||||
const service = accessor.untitledEditorService;
|
||||
const input = service.createOrGet(undefined, undefined, 'Hello World');
|
||||
|
||||
// dirty
|
||||
const model = await input.resolve();
|
||||
assert.ok(model.isDirty());
|
||||
input.dispose();
|
||||
});
|
||||
|
||||
test('Untitled created with files.defaultLanguage setting', () => {
|
||||
test('Untitled created with files.defaultLanguage setting', function () {
|
||||
const defaultLanguage = 'javascript';
|
||||
const config = accessor.testConfigurationService;
|
||||
config.setUserConfiguration('files', { 'defaultLanguage': defaultLanguage });
|
||||
@@ -191,52 +188,30 @@ suite('Workbench untitled editors', () => {
|
||||
const service = accessor.untitledEditorService;
|
||||
const input = service.createOrGet();
|
||||
|
||||
assert.equal(input.getMode(), defaultLanguage);
|
||||
assert.equal(input.getModeId(), defaultLanguage);
|
||||
|
||||
config.setUserConfiguration('files', { 'defaultLanguage': undefined });
|
||||
|
||||
input.dispose();
|
||||
});
|
||||
|
||||
test('Untitled created with mode overrides files.defaultLanguage setting', () => {
|
||||
const mode = 'typescript';
|
||||
test('Untitled created with modeId overrides files.defaultLanguage setting', function () {
|
||||
const modeId = 'typescript';
|
||||
const defaultLanguage = 'javascript';
|
||||
const config = accessor.testConfigurationService;
|
||||
config.setUserConfiguration('files', { 'defaultLanguage': defaultLanguage });
|
||||
|
||||
const service = accessor.untitledEditorService;
|
||||
const input = service.createOrGet(null!, mode);
|
||||
const input = service.createOrGet(null!, modeId);
|
||||
|
||||
assert.equal(input.getMode(), mode);
|
||||
assert.equal(input.getModeId(), modeId);
|
||||
|
||||
config.setUserConfiguration('files', { 'defaultLanguage': undefined });
|
||||
|
||||
input.dispose();
|
||||
});
|
||||
|
||||
test('Untitled can change mode afterwards', async () => {
|
||||
const mode = 'untitled-input-test';
|
||||
|
||||
ModesRegistry.registerLanguage({
|
||||
id: mode,
|
||||
});
|
||||
|
||||
const service = accessor.untitledEditorService;
|
||||
const input = service.createOrGet(null!, mode);
|
||||
|
||||
assert.equal(input.getMode(), mode);
|
||||
|
||||
const model = await input.resolve();
|
||||
assert.equal(model.getMode(), mode);
|
||||
|
||||
input.setMode('text');
|
||||
|
||||
assert.equal(input.getMode(), PLAINTEXT_MODE_ID);
|
||||
|
||||
input.dispose();
|
||||
});
|
||||
|
||||
test('encoding change event', async () => {
|
||||
test('encoding change event', function () {
|
||||
const service = accessor.untitledEditorService;
|
||||
const input = service.createOrGet();
|
||||
|
||||
@@ -248,13 +223,16 @@ suite('Workbench untitled editors', () => {
|
||||
});
|
||||
|
||||
// dirty
|
||||
const model = await input.resolve();
|
||||
model.setEncoding('utf16');
|
||||
assert.equal(counter, 1);
|
||||
input.dispose();
|
||||
return input.resolve().then(model => {
|
||||
model.setEncoding('utf16');
|
||||
|
||||
assert.equal(counter, 1);
|
||||
|
||||
input.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
test('onDidChangeContent event', async () => {
|
||||
test('onDidChangeContent event', () => {
|
||||
const service = accessor.untitledEditorService;
|
||||
const input = service.createOrGet();
|
||||
|
||||
@@ -267,32 +245,39 @@ suite('Workbench untitled editors', () => {
|
||||
assert.equal(r.toString(), input.getResource().toString());
|
||||
});
|
||||
|
||||
const model = await input.resolve();
|
||||
model.textEditorModel.setValue('foo');
|
||||
assert.equal(counter, 0, 'Dirty model should not trigger event immediately');
|
||||
return input.resolve().then(model => {
|
||||
model.textEditorModel.setValue('foo');
|
||||
assert.equal(counter, 0, 'Dirty model should not trigger event immediately');
|
||||
|
||||
await timeout(3);
|
||||
assert.equal(counter, 1, 'Dirty model should trigger event');
|
||||
model.textEditorModel.setValue('bar');
|
||||
return timeout(3).then(() => {
|
||||
assert.equal(counter, 1, 'Dirty model should trigger event');
|
||||
|
||||
await timeout(3);
|
||||
assert.equal(counter, 2, 'Content change when dirty should trigger event');
|
||||
model.textEditorModel.setValue('');
|
||||
model.textEditorModel.setValue('bar');
|
||||
return timeout(3).then(() => {
|
||||
assert.equal(counter, 2, 'Content change when dirty should trigger event');
|
||||
|
||||
await timeout(3);
|
||||
assert.equal(counter, 3, 'Manual revert should trigger event');
|
||||
model.textEditorModel.setValue('foo');
|
||||
model.textEditorModel.setValue('');
|
||||
return timeout(3).then(() => {
|
||||
assert.equal(counter, 3, 'Manual revert should trigger event');
|
||||
|
||||
await timeout(3);
|
||||
assert.equal(counter, 4, 'Dirty model should trigger event');
|
||||
model.revert();
|
||||
model.textEditorModel.setValue('foo');
|
||||
return timeout(3).then(() => {
|
||||
assert.equal(counter, 4, 'Dirty model should trigger event');
|
||||
|
||||
await timeout(3);
|
||||
assert.equal(counter, 5, 'Revert should trigger event');
|
||||
input.dispose();
|
||||
model.revert();
|
||||
return timeout(3).then(() => {
|
||||
assert.equal(counter, 5, 'Revert should trigger event');
|
||||
|
||||
input.dispose();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('onDidDisposeModel event', async () => {
|
||||
test('onDidDisposeModel event', () => {
|
||||
const service = accessor.untitledEditorService;
|
||||
const input = service.createOrGet();
|
||||
|
||||
@@ -303,9 +288,10 @@ suite('Workbench untitled editors', () => {
|
||||
assert.equal(r.toString(), input.getResource().toString());
|
||||
});
|
||||
|
||||
await input.resolve();
|
||||
assert.equal(counter, 0);
|
||||
input.dispose();
|
||||
assert.equal(counter, 1);
|
||||
return input.resolve().then(model => {
|
||||
assert.equal(counter, 0);
|
||||
input.dispose();
|
||||
assert.equal(counter, 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -37,7 +37,7 @@ suite('MainThreadSaveParticipant', function () {
|
||||
});
|
||||
|
||||
test('insert final new line', async function () {
|
||||
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/final_new_line.txt'), 'utf8', undefined) as IResolvedTextFileEditorModel;
|
||||
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/final_new_line.txt'), 'utf8') as IResolvedTextFileEditorModel;
|
||||
|
||||
await model.load();
|
||||
const configService = new TestConfigurationService();
|
||||
@@ -70,7 +70,7 @@ suite('MainThreadSaveParticipant', function () {
|
||||
});
|
||||
|
||||
test('trim final new lines', async function () {
|
||||
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/trim_final_new_line.txt'), 'utf8', undefined) as IResolvedTextFileEditorModel;
|
||||
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/trim_final_new_line.txt'), 'utf8') as IResolvedTextFileEditorModel;
|
||||
|
||||
await model.load();
|
||||
const configService = new TestConfigurationService();
|
||||
@@ -105,7 +105,7 @@ suite('MainThreadSaveParticipant', function () {
|
||||
});
|
||||
|
||||
test('trim final new lines bug#39750', async function () {
|
||||
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/trim_final_new_line.txt'), 'utf8', undefined) as IResolvedTextFileEditorModel;
|
||||
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/trim_final_new_line.txt'), 'utf8') as IResolvedTextFileEditorModel;
|
||||
|
||||
await model.load();
|
||||
const configService = new TestConfigurationService();
|
||||
@@ -132,7 +132,7 @@ suite('MainThreadSaveParticipant', function () {
|
||||
});
|
||||
|
||||
test('trim final new lines bug#46075', async function () {
|
||||
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/trim_final_new_line.txt'), 'utf8', undefined) as IResolvedTextFileEditorModel;
|
||||
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/trim_final_new_line.txt'), 'utf8') as IResolvedTextFileEditorModel;
|
||||
|
||||
await model.load();
|
||||
const configService = new TestConfigurationService();
|
||||
|
||||
@@ -15,7 +15,7 @@ import { ConfirmResult, IEditorInputWithOptions, CloseDirection, IEditorIdentifi
|
||||
import { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { IBackupFileService, IResolvedBackup } from 'vs/workbench/services/backup/common/backup';
|
||||
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IWorkbenchLayoutService, Parts, Position as PartPosition } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
|
||||
@@ -85,7 +85,7 @@ import { VSBuffer, VSBufferReadable } from 'vs/base/common/buffer';
|
||||
import { BrowserTextFileService } from 'vs/workbench/services/textfile/browser/textFileService';
|
||||
|
||||
export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
|
||||
return instantiationService.createInstance(FileEditorInput, resource, undefined, undefined);
|
||||
return instantiationService.createInstance(FileEditorInput, resource, undefined);
|
||||
}
|
||||
|
||||
export const TestEnvironmentService = new WorkbenchEnvironmentService(parseArgs(process.argv) as IWindowConfiguration, process.execPath);
|
||||
@@ -1093,7 +1093,7 @@ export class TestBackupFileService implements IBackupFileService {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
public backupResource<T extends object>(_resource: URI, _content: ITextSnapshot, versionId?: number, meta?: T): Promise<void> {
|
||||
public backupResource(_resource: URI, _content: ITextSnapshot): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -1108,7 +1108,7 @@ export class TestBackupFileService implements IBackupFileService {
|
||||
return textBuffer.getValueInRange(range, EndOfLinePreference.TextDefined);
|
||||
}
|
||||
|
||||
public resolveBackupContent<T extends object>(_backup: URI): Promise<IResolvedBackup<T>> {
|
||||
public resolveBackupContent(_backup: URI): Promise<ITextBufferFactory> {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user