mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode a234f13c45b40a0929777cb440ee011b7549eed2 (#8911)
* Merge from vscode a234f13c45b40a0929777cb440ee011b7549eed2 * update distro * fix layering * update distro * fix tests
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ContributableViewsModel, ViewsService, IViewState } from 'vs/workbench/browser/parts/views/views';
|
||||
import { IViewsRegistry, IViewDescriptor, IViewContainersRegistry, Extensions as ViewContainerExtensions, IViewsService, ViewContainerLocation } from 'vs/workbench/common/views';
|
||||
import { ContributableViewsModel, ViewDescriptorService, IViewState } from 'vs/workbench/browser/parts/views/views';
|
||||
import { IViewsRegistry, IViewDescriptor, IViewContainersRegistry, Extensions as ViewContainerExtensions, IViewDescriptorService, ViewContainerLocation } from 'vs/workbench/common/views';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { move } from 'vs/base/common/arrays';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
@@ -14,8 +14,9 @@ import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/commo
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyService';
|
||||
import sinon = require('sinon');
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
|
||||
const container = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer({ id: 'test', name: 'test', ctorDescriptor: { ctor: <any>{} } }, ViewContainerLocation.Sidebar);
|
||||
const container = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer({ id: 'test', name: 'test', ctorDescriptor: new SyncDescriptor(<any>{}) }, ViewContainerLocation.Sidebar);
|
||||
const ViewsRegistry = Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry);
|
||||
|
||||
class ViewDescriptorSequence {
|
||||
@@ -37,14 +38,14 @@ class ViewDescriptorSequence {
|
||||
|
||||
suite('ContributableViewsModel', () => {
|
||||
|
||||
let viewsService: IViewsService;
|
||||
let viewDescriptorService: IViewDescriptorService;
|
||||
let contextKeyService: IContextKeyService;
|
||||
|
||||
setup(() => {
|
||||
const instantiationService: TestInstantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
contextKeyService = instantiationService.createInstance(ContextKeyService);
|
||||
instantiationService.stub(IContextKeyService, contextKeyService);
|
||||
viewsService = instantiationService.createInstance(ViewsService);
|
||||
viewDescriptorService = instantiationService.createInstance(ViewDescriptorService);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -52,12 +53,12 @@ suite('ContributableViewsModel', () => {
|
||||
});
|
||||
|
||||
test('empty model', function () {
|
||||
const model = new ContributableViewsModel(container, viewsService);
|
||||
const model = new ContributableViewsModel(container, viewDescriptorService);
|
||||
assert.equal(model.visibleViewDescriptors.length, 0);
|
||||
});
|
||||
|
||||
test('register/unregister', () => {
|
||||
const model = new ContributableViewsModel(container, viewsService);
|
||||
const model = new ContributableViewsModel(container, viewDescriptorService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
assert.equal(model.visibleViewDescriptors.length, 0);
|
||||
@@ -83,7 +84,7 @@ suite('ContributableViewsModel', () => {
|
||||
});
|
||||
|
||||
test('when contexts', async function () {
|
||||
const model = new ContributableViewsModel(container, viewsService);
|
||||
const model = new ContributableViewsModel(container, viewDescriptorService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
assert.equal(model.visibleViewDescriptors.length, 0);
|
||||
@@ -127,7 +128,7 @@ suite('ContributableViewsModel', () => {
|
||||
});
|
||||
|
||||
test('when contexts - multiple', async function () {
|
||||
const model = new ContributableViewsModel(container, viewsService);
|
||||
const model = new ContributableViewsModel(container, viewDescriptorService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
const view1: IViewDescriptor = { id: 'view1', ctorDescriptor: null!, name: 'Test View 1' };
|
||||
@@ -150,7 +151,7 @@ suite('ContributableViewsModel', () => {
|
||||
});
|
||||
|
||||
test('when contexts - multiple 2', async function () {
|
||||
const model = new ContributableViewsModel(container, viewsService);
|
||||
const model = new ContributableViewsModel(container, viewDescriptorService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
const view1: IViewDescriptor = { id: 'view1', ctorDescriptor: null!, name: 'Test View 1', when: ContextKeyExpr.equals('showview1', true) };
|
||||
@@ -173,7 +174,7 @@ suite('ContributableViewsModel', () => {
|
||||
});
|
||||
|
||||
test('setVisible', () => {
|
||||
const model = new ContributableViewsModel(container, viewsService);
|
||||
const model = new ContributableViewsModel(container, viewDescriptorService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
const view1: IViewDescriptor = { id: 'view1', ctorDescriptor: null!, name: 'Test View 1', canToggleVisibility: true };
|
||||
@@ -218,7 +219,7 @@ suite('ContributableViewsModel', () => {
|
||||
});
|
||||
|
||||
test('move', () => {
|
||||
const model = new ContributableViewsModel(container, viewsService);
|
||||
const model = new ContributableViewsModel(container, viewDescriptorService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
const view1: IViewDescriptor = { id: 'view1', ctorDescriptor: null!, name: 'Test View 1' };
|
||||
@@ -249,7 +250,7 @@ suite('ContributableViewsModel', () => {
|
||||
test('view states', async function () {
|
||||
const viewStates = new Map<string, IViewState>();
|
||||
viewStates.set('view1', { visibleGlobal: false, collapsed: false, visibleWorkspace: undefined });
|
||||
const model = new ContributableViewsModel(container, viewsService, viewStates);
|
||||
const model = new ContributableViewsModel(container, viewDescriptorService, viewStates);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
assert.equal(model.visibleViewDescriptors.length, 0);
|
||||
@@ -269,7 +270,7 @@ suite('ContributableViewsModel', () => {
|
||||
test('view states and when contexts', async function () {
|
||||
const viewStates = new Map<string, IViewState>();
|
||||
viewStates.set('view1', { visibleGlobal: false, collapsed: false, visibleWorkspace: undefined });
|
||||
const model = new ContributableViewsModel(container, viewsService, viewStates);
|
||||
const model = new ContributableViewsModel(container, viewDescriptorService, viewStates);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
assert.equal(model.visibleViewDescriptors.length, 0);
|
||||
@@ -299,7 +300,7 @@ suite('ContributableViewsModel', () => {
|
||||
test('view states and when contexts multiple views', async function () {
|
||||
const viewStates = new Map<string, IViewState>();
|
||||
viewStates.set('view1', { visibleGlobal: false, collapsed: false, visibleWorkspace: undefined });
|
||||
const model = new ContributableViewsModel(container, viewsService, viewStates);
|
||||
const model = new ContributableViewsModel(container, viewDescriptorService, viewStates);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
assert.equal(model.visibleViewDescriptors.length, 0);
|
||||
@@ -343,7 +344,7 @@ suite('ContributableViewsModel', () => {
|
||||
});
|
||||
|
||||
test('remove event is not triggered if view was hidden and removed', async function () {
|
||||
const model = new ContributableViewsModel(container, viewsService);
|
||||
const model = new ContributableViewsModel(container, viewDescriptorService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
const viewDescriptor: IViewDescriptor = {
|
||||
|
||||
@@ -14,8 +14,7 @@ import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestSe
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
class ServiceAccessor {
|
||||
constructor(@IUntitledTextEditorService public untitledTextEditorService: UntitledTextEditorService) {
|
||||
}
|
||||
constructor(@IUntitledTextEditorService public untitledTextEditorService: UntitledTextEditorService) { }
|
||||
}
|
||||
|
||||
class FileEditorInput extends EditorInput {
|
||||
@@ -48,7 +47,6 @@ suite('Workbench editor', () => {
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
accessor.untitledTextEditorService.revertAll();
|
||||
accessor.untitledTextEditorService.dispose();
|
||||
});
|
||||
|
||||
@@ -57,7 +55,7 @@ suite('Workbench editor', () => {
|
||||
|
||||
assert.ok(!toResource(null!));
|
||||
|
||||
const untitled = service.createOrGet();
|
||||
const untitled = service.create();
|
||||
|
||||
assert.equal(toResource(untitled)!.toString(), untitled.getResource().toString());
|
||||
assert.equal(toResource(untitled, { supportSideBySide: SideBySideEditor.MASTER })!.toString(), untitled.getResource().toString());
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { EditorOptions, TextEditorOptions } from 'vs/workbench/common/editor';
|
||||
|
||||
suite('Workbench editor options', () => {
|
||||
|
||||
test('EditorOptions', () => {
|
||||
let options = new EditorOptions();
|
||||
|
||||
assert(!options.preserveFocus);
|
||||
options.preserveFocus = true;
|
||||
assert(options.preserveFocus);
|
||||
assert(!options.forceReload);
|
||||
options.forceReload = true;
|
||||
assert(options.forceReload);
|
||||
|
||||
options = new EditorOptions();
|
||||
options.forceReload = true;
|
||||
});
|
||||
|
||||
test('TextEditorOptions', () => {
|
||||
let options = new TextEditorOptions();
|
||||
let otherOptions = new TextEditorOptions();
|
||||
|
||||
assert(!options.hasOptionsDefined());
|
||||
options.selection(1, 1, 2, 2);
|
||||
assert(options.hasOptionsDefined());
|
||||
|
||||
otherOptions.selection(1, 1, 2, 2);
|
||||
|
||||
options = new TextEditorOptions();
|
||||
options.forceReload = true;
|
||||
options.selection(1, 1, 2, 2);
|
||||
});
|
||||
});
|
||||
@@ -9,28 +9,22 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { UntitledTextEditorModel } from 'vs/workbench/common/editor/untitledTextEditorModel';
|
||||
import { workbenchInstantiationService, TestEditorService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/common/editor/untitledTextEditorInput';
|
||||
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';
|
||||
import { IWorkingCopyService, IWorkingCopy } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
|
||||
export class TestUntitledTextEditorService extends UntitledTextEditorService {
|
||||
get(resource: URI) { return super.get(resource); }
|
||||
getAll(resources?: URI[]): UntitledTextEditorInput[] { return super.getAll(resources); }
|
||||
}
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
|
||||
class ServiceAccessor {
|
||||
constructor(
|
||||
@IUntitledTextEditorService public readonly untitledTextEditorService: TestUntitledTextEditorService,
|
||||
@IUntitledTextEditorService public readonly untitledTextEditorService: IUntitledTextEditorService,
|
||||
@IEditorService public readonly editorService: TestEditorService,
|
||||
@IWorkingCopyService public readonly workingCopyService: IWorkingCopyService,
|
||||
@IModeService public readonly modeService: ModeServiceImpl,
|
||||
@IConfigurationService public readonly testConfigurationService: TestConfigurationService) {
|
||||
}
|
||||
@IConfigurationService public readonly testConfigurationService: TestConfigurationService
|
||||
) { }
|
||||
}
|
||||
|
||||
suite('Workbench untitled text editors', () => {
|
||||
@@ -44,63 +38,52 @@ suite('Workbench untitled text editors', () => {
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
accessor.untitledTextEditorService.revertAll();
|
||||
accessor.untitledTextEditorService.dispose();
|
||||
(accessor.untitledTextEditorService as UntitledTextEditorService).dispose();
|
||||
});
|
||||
|
||||
test('Untitled Text Editor Service', async (done) => {
|
||||
const service = accessor.untitledTextEditorService;
|
||||
const workingCopyService = accessor.workingCopyService;
|
||||
|
||||
assert.equal(service.getAll().length, 0);
|
||||
|
||||
let createdResources: URI[] = [];
|
||||
const createListener = service.onDidCreate(resource => {
|
||||
createdResources.push(resource);
|
||||
});
|
||||
|
||||
const input1 = service.createOrGet();
|
||||
assert.equal(input1, service.createOrGet(input1.getResource()));
|
||||
const input1 = service.create();
|
||||
assert.equal(input1, service.create({ untitledResource: input1.getResource() }));
|
||||
assert.equal(service.get(input1.getResource()), input1);
|
||||
|
||||
assert.ok(service.exists(input1.getResource()));
|
||||
assert.ok(!service.exists(URI.file('testing')));
|
||||
assert.equal(createdResources.length, 1);
|
||||
assert.equal(createdResources[0].toString(), input1.getResource());
|
||||
|
||||
createListener.dispose();
|
||||
const input2 = service.create();
|
||||
assert.equal(service.get(input2.getResource()), input2);
|
||||
|
||||
const input2 = service.createOrGet();
|
||||
|
||||
// get() / getAll()
|
||||
// get()
|
||||
assert.equal(service.get(input1.getResource()), input1);
|
||||
assert.equal(service.getAll().length, 2);
|
||||
assert.equal(service.getAll([input1.getResource(), input2.getResource()]).length, 2);
|
||||
assert.equal(service.get(input2.getResource()), input2);
|
||||
|
||||
// revertAll()
|
||||
service.revertAll([input1.getResource()]);
|
||||
// revert()
|
||||
input1.revert();
|
||||
assert.ok(input1.isDisposed());
|
||||
assert.equal(service.getAll().length, 1);
|
||||
assert.ok(!service.get(input1.getResource()));
|
||||
|
||||
// dirty
|
||||
const model = await input2.resolve();
|
||||
assert.equal(await service.resolve({ untitledResource: input2.getResource() }), model);
|
||||
|
||||
assert.ok(!service.isDirty(input2.getResource()));
|
||||
assert.ok(!input2.isDirty());
|
||||
|
||||
const listener = service.onDidChangeDirty(resource => {
|
||||
listener.dispose();
|
||||
|
||||
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(input2.isDirty());
|
||||
|
||||
assert.ok(workingCopyService.isDirty(input2.getResource()));
|
||||
assert.equal(workingCopyService.dirtyCount, 1);
|
||||
|
||||
service.revertAll();
|
||||
assert.equal(service.getAll().length, 0);
|
||||
input1.revert();
|
||||
input2.revert();
|
||||
assert.ok(!service.get(input1.getResource()));
|
||||
assert.ok(!service.get(input2.getResource()));
|
||||
assert.ok(!input2.isDirty());
|
||||
assert.ok(!model.isDirty());
|
||||
|
||||
@@ -118,22 +101,26 @@ suite('Workbench untitled text editors', () => {
|
||||
});
|
||||
|
||||
model.textEditorModel.setValue('foo bar');
|
||||
model.dispose();
|
||||
input1.dispose();
|
||||
input2.dispose();
|
||||
});
|
||||
|
||||
test('Untitled with associated resource', () => {
|
||||
test('Untitled with associated resource is dirty', () => {
|
||||
const service = accessor.untitledTextEditorService;
|
||||
const file = URI.file(join('C:\\', '/foo/file.txt'));
|
||||
const untitled = service.createOrGet(file);
|
||||
const untitled = service.create({ associatedResource: file });
|
||||
|
||||
assert.ok(service.hasAssociatedFilePath(untitled.getResource()));
|
||||
assert.equal(untitled.isDirty(), true);
|
||||
|
||||
untitled.dispose();
|
||||
});
|
||||
|
||||
test('Untitled no longer dirty when content gets empty', async () => {
|
||||
test('Untitled no longer dirty when content gets empty (not with associated resource)', async () => {
|
||||
const service = accessor.untitledTextEditorService;
|
||||
const workingCopyService = accessor.workingCopyService;
|
||||
const input = service.createOrGet();
|
||||
const input = service.create();
|
||||
|
||||
// dirty
|
||||
const model = await input.resolve();
|
||||
@@ -144,12 +131,13 @@ suite('Workbench untitled text editors', () => {
|
||||
assert.ok(!model.isDirty());
|
||||
assert.ok(!workingCopyService.isDirty(model.resource));
|
||||
input.dispose();
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('Untitled via loadOrCreate', async () => {
|
||||
test('Untitled via create options', async () => {
|
||||
const service = accessor.untitledTextEditorService;
|
||||
|
||||
const model1 = await service.loadOrCreate();
|
||||
const model1 = await service.create().resolve();
|
||||
|
||||
model1.textEditorModel!.setValue('foo bar');
|
||||
assert.ok(model1.isDirty());
|
||||
@@ -157,17 +145,17 @@ suite('Workbench untitled text editors', () => {
|
||||
model1.textEditorModel!.setValue('');
|
||||
assert.ok(!model1.isDirty());
|
||||
|
||||
const model2 = await service.loadOrCreate({ initialValue: 'Hello World' });
|
||||
const model2 = await service.create({ initialValue: 'Hello World' }).resolve();
|
||||
assert.equal(snapshotToString(model2.createSnapshot()!), 'Hello World');
|
||||
|
||||
const input = service.createOrGet();
|
||||
const input = service.create();
|
||||
|
||||
const model3 = await service.loadOrCreate({ resource: input.getResource() });
|
||||
const model3 = await service.create({ untitledResource: input.getResource() }).resolve();
|
||||
|
||||
assert.equal(model3.resource.toString(), input.getResource().toString());
|
||||
|
||||
const file = URI.file(join('C:\\', '/foo/file44.txt'));
|
||||
const model4 = await service.loadOrCreate({ resource: file });
|
||||
const model4 = await service.create({ associatedResource: file }).resolve();
|
||||
assert.ok(service.hasAssociatedFilePath(model4.resource));
|
||||
assert.ok(model4.isDirty());
|
||||
|
||||
@@ -180,15 +168,16 @@ suite('Workbench untitled text editors', () => {
|
||||
|
||||
test('Untitled suggest name', function () {
|
||||
const service = accessor.untitledTextEditorService;
|
||||
const input = service.createOrGet();
|
||||
const input = service.create();
|
||||
|
||||
assert.ok(service.suggestFileName(input.getResource()));
|
||||
assert.ok(input.suggestFileName().length > 0);
|
||||
input.dispose();
|
||||
});
|
||||
|
||||
test('Untitled with associated path remains dirty when content gets empty', async () => {
|
||||
const service = accessor.untitledTextEditorService;
|
||||
const file = URI.file(join('C:\\', '/foo/file.txt'));
|
||||
const input = service.createOrGet(file);
|
||||
const input = service.create({ associatedResource: file });
|
||||
|
||||
// dirty
|
||||
const model = await input.resolve();
|
||||
@@ -197,26 +186,30 @@ suite('Workbench untitled text editors', () => {
|
||||
model.textEditorModel.setValue('');
|
||||
assert.ok(model.isDirty());
|
||||
input.dispose();
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('Untitled with initial content is dirty', async () => {
|
||||
const service = accessor.untitledTextEditorService;
|
||||
const input = service.createOrGet(undefined, undefined, 'Hello World');
|
||||
const workingCopyService = accessor.workingCopyService;
|
||||
|
||||
const untitled = service.create({ initialValue: 'Hello World' });
|
||||
assert.equal(untitled.isDirty(), true);
|
||||
|
||||
let onDidChangeDirty: IWorkingCopy | undefined = undefined;
|
||||
const listener = workingCopyService.onDidChangeDirty(copy => {
|
||||
onDidChangeDirty = copy;
|
||||
});
|
||||
|
||||
// dirty
|
||||
const model = await input.resolve();
|
||||
const model = await untitled.resolve();
|
||||
assert.ok(model.isDirty());
|
||||
assert.equal(workingCopyService.dirtyCount, 1);
|
||||
assert.equal(onDidChangeDirty, model);
|
||||
|
||||
input.dispose();
|
||||
untitled.dispose();
|
||||
listener.dispose();
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('Untitled created with files.defaultLanguage setting', () => {
|
||||
@@ -225,7 +218,7 @@ suite('Workbench untitled text editors', () => {
|
||||
config.setUserConfiguration('files', { 'defaultLanguage': defaultLanguage });
|
||||
|
||||
const service = accessor.untitledTextEditorService;
|
||||
const input = service.createOrGet();
|
||||
const input = service.create();
|
||||
|
||||
assert.equal(input.getMode(), defaultLanguage);
|
||||
|
||||
@@ -234,6 +227,23 @@ suite('Workbench untitled text editors', () => {
|
||||
input.dispose();
|
||||
});
|
||||
|
||||
test('Untitled created with files.defaultLanguage setting (${activeEditorLanguage})', () => {
|
||||
const config = accessor.testConfigurationService;
|
||||
config.setUserConfiguration('files', { 'defaultLanguage': '${activeEditorLanguage}' });
|
||||
|
||||
accessor.editorService.activeTextEditorMode = 'typescript';
|
||||
|
||||
const service = accessor.untitledTextEditorService;
|
||||
const input = service.create();
|
||||
|
||||
assert.equal(input.getMode(), 'typescript');
|
||||
|
||||
config.setUserConfiguration('files', { 'defaultLanguage': undefined });
|
||||
accessor.editorService.activeTextEditorMode = undefined;
|
||||
|
||||
input.dispose();
|
||||
});
|
||||
|
||||
test('Untitled created with mode overrides files.defaultLanguage setting', () => {
|
||||
const mode = 'typescript';
|
||||
const defaultLanguage = 'javascript';
|
||||
@@ -241,7 +251,7 @@ suite('Workbench untitled text editors', () => {
|
||||
config.setUserConfiguration('files', { 'defaultLanguage': defaultLanguage });
|
||||
|
||||
const service = accessor.untitledTextEditorService;
|
||||
const input = service.createOrGet(null!, mode);
|
||||
const input = service.create({ mode });
|
||||
|
||||
assert.equal(input.getMode(), mode);
|
||||
|
||||
@@ -258,7 +268,7 @@ suite('Workbench untitled text editors', () => {
|
||||
});
|
||||
|
||||
const service = accessor.untitledTextEditorService;
|
||||
const input = service.createOrGet(null!, mode);
|
||||
const input = service.create({ mode });
|
||||
|
||||
assert.equal(input.getMode(), mode);
|
||||
|
||||
@@ -270,11 +280,12 @@ suite('Workbench untitled text editors', () => {
|
||||
assert.equal(input.getMode(), PLAINTEXT_MODE_ID);
|
||||
|
||||
input.dispose();
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('encoding change event', async () => {
|
||||
const service = accessor.untitledTextEditorService;
|
||||
const input = service.createOrGet();
|
||||
const input = service.create();
|
||||
|
||||
let counter = 0;
|
||||
|
||||
@@ -288,49 +299,58 @@ suite('Workbench untitled text editors', () => {
|
||||
model.setEncoding('utf16');
|
||||
assert.equal(counter, 1);
|
||||
input.dispose();
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('onDidChangeContent event', async () => {
|
||||
test('onDidChangeContent event', async function () {
|
||||
const service = accessor.untitledTextEditorService;
|
||||
const input = service.createOrGet();
|
||||
|
||||
UntitledTextEditorModel.DEFAULT_CONTENT_CHANGE_BUFFER_DELAY = 0;
|
||||
const input = service.create();
|
||||
|
||||
let counter = 0;
|
||||
|
||||
service.onDidChangeContent(r => {
|
||||
counter++;
|
||||
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');
|
||||
model.onDidChangeContent(() => counter++);
|
||||
|
||||
model.textEditorModel.setValue('foo');
|
||||
|
||||
await timeout(3);
|
||||
assert.equal(counter, 1, 'Dirty model should trigger event');
|
||||
model.textEditorModel.setValue('bar');
|
||||
|
||||
await timeout(3);
|
||||
assert.equal(counter, 2, 'Content change when dirty should trigger event');
|
||||
model.textEditorModel.setValue('');
|
||||
|
||||
await timeout(3);
|
||||
assert.equal(counter, 3, 'Manual revert should trigger event');
|
||||
model.textEditorModel.setValue('foo');
|
||||
|
||||
await timeout(3);
|
||||
assert.equal(counter, 4, 'Dirty model should trigger event');
|
||||
model.revert();
|
||||
|
||||
await timeout(3);
|
||||
assert.equal(counter, 5, 'Revert should trigger event');
|
||||
input.dispose();
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('onDidChangeDirty event', async function () {
|
||||
const service = accessor.untitledTextEditorService;
|
||||
const input = service.create();
|
||||
|
||||
let counter = 0;
|
||||
|
||||
const model = await input.resolve();
|
||||
model.onDidChangeDirty(() => counter++);
|
||||
|
||||
model.textEditorModel.setValue('foo');
|
||||
|
||||
assert.equal(counter, 1, 'Dirty model should trigger event');
|
||||
model.textEditorModel.setValue('bar');
|
||||
|
||||
assert.equal(counter, 1, 'Another change does not fire event');
|
||||
|
||||
input.dispose();
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('onDidDisposeModel event', async () => {
|
||||
const service = accessor.untitledTextEditorService;
|
||||
const input = service.createOrGet();
|
||||
const input = service.create();
|
||||
|
||||
let counter = 0;
|
||||
|
||||
@@ -339,9 +359,10 @@ suite('Workbench untitled text editors', () => {
|
||||
assert.equal(r.toString(), input.getResource().toString());
|
||||
});
|
||||
|
||||
await input.resolve();
|
||||
const model = await input.resolve();
|
||||
assert.equal(counter, 0);
|
||||
input.dispose();
|
||||
assert.equal(counter, 1);
|
||||
model.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { MainContext, ExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostDiagnostics } from 'vs/workbench/api/common/extHostDiagnostics';
|
||||
import * as vscode from 'vscode';
|
||||
import type * as vscode from 'vscode';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import 'vs/workbench/contrib/search/browser/search.contribution';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
@@ -32,6 +32,7 @@ import { nullExtensionDescription } from 'vs/workbench/services/extensions/commo
|
||||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import { NullApiDeprecationService } from 'vs/workbench/api/common/extHostApiDeprecationService';
|
||||
|
||||
const defaultSelector = { scheme: 'far' };
|
||||
const model: ITextModel = EditorModel.createFromString(
|
||||
@@ -122,7 +123,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
const diagnostics = new ExtHostDiagnostics(rpcProtocol, new NullLogService());
|
||||
rpcProtocol.set(ExtHostContext.ExtHostDiagnostics, diagnostics);
|
||||
|
||||
extHost = new ExtHostLanguageFeatures(rpcProtocol, null, extHostDocuments, commands, diagnostics, new NullLogService());
|
||||
extHost = new ExtHostLanguageFeatures(rpcProtocol, null, extHostDocuments, commands, diagnostics, new NullLogService(), NullApiDeprecationService);
|
||||
rpcProtocol.set(ExtHostContext.ExtHostLanguageFeatures, extHost);
|
||||
|
||||
mainThread = rpcProtocol.set(MainContext.MainThreadLanguageFeatures, inst.createInstance(MainThreadLanguageFeatures, rpcProtocol));
|
||||
|
||||
@@ -33,8 +33,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
assert.throws(() => collection.name);
|
||||
assert.throws(() => collection.clear());
|
||||
assert.throws(() => collection.delete(URI.parse('aa:bb')));
|
||||
// tslint:disable-next-line:semicolon
|
||||
assert.throws(() => collection.forEach(() => { ; }));
|
||||
assert.throws(() => collection.forEach(() => { }));
|
||||
assert.throws(() => collection.get(URI.parse('aa:bb')));
|
||||
assert.throws(() => collection.has(URI.parse('aa:bb')));
|
||||
assert.throws(() => collection.set(URI.parse('aa:bb'), []));
|
||||
|
||||
@@ -11,10 +11,10 @@ import { MainThreadTextEditorsShape, IWorkspaceEditDto } from 'vs/workbench/api/
|
||||
import { ExtHostDocumentSaveParticipant } from 'vs/workbench/api/common/extHostDocumentSaveParticipant';
|
||||
import { SingleProxyRPCProtocol } from './testRPCProtocol';
|
||||
import { SaveReason } from 'vs/workbench/common/editor';
|
||||
import * as vscode from 'vscode';
|
||||
import type * as vscode from 'vscode';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { isResourceTextEdit, ResourceTextEdit } from 'vs/editor/common/modes';
|
||||
import { WorkspaceTextEdit } from 'vs/editor/common/modes';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
@@ -279,8 +279,8 @@ suite('ExtHostDocumentSaveParticipant', () => {
|
||||
sub.dispose();
|
||||
|
||||
assert.equal(dto.edits.length, 1);
|
||||
assert.ok(isResourceTextEdit(dto.edits[0]));
|
||||
assert.equal((<ResourceTextEdit>dto.edits[0]).edits.length, 2);
|
||||
assert.ok(WorkspaceTextEdit.is(dto.edits[0]));
|
||||
assert.equal((<WorkspaceTextEdit>dto.edits[0]).edits.length, 2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -326,7 +326,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
|
||||
$tryApplyWorkspaceEdit(dto: IWorkspaceEditDto) {
|
||||
|
||||
for (const edit of dto.edits) {
|
||||
if (!isResourceTextEdit(edit)) {
|
||||
if (!WorkspaceTextEdit.is(edit)) {
|
||||
continue;
|
||||
}
|
||||
const { resource, edits } = edit;
|
||||
|
||||
@@ -35,7 +35,7 @@ import { getDocumentFormattingEditsUntilResult, getDocumentRangeFormattingEditsU
|
||||
import { getLinks } from 'vs/editor/contrib/links/getLinks';
|
||||
import { MainContext, ExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostDiagnostics } from 'vs/workbench/api/common/extHostDiagnostics';
|
||||
import * as vscode from 'vscode';
|
||||
import type * as vscode from 'vscode';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { ITextModel, EndOfLineSequence } from 'vs/editor/common/model';
|
||||
@@ -47,6 +47,7 @@ import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { NullApiDeprecationService } from 'vs/workbench/api/common/extHostApiDeprecationService';
|
||||
|
||||
const defaultSelector = { scheme: 'far' };
|
||||
const model: ITextModel = EditorModel.createFromString(
|
||||
@@ -105,7 +106,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
const diagnostics = new ExtHostDiagnostics(rpcProtocol, new NullLogService());
|
||||
rpcProtocol.set(ExtHostContext.ExtHostDiagnostics, diagnostics);
|
||||
|
||||
extHost = new ExtHostLanguageFeatures(rpcProtocol, null, extHostDocuments, commands, diagnostics, new NullLogService());
|
||||
extHost = new ExtHostLanguageFeatures(rpcProtocol, null, extHostDocuments, commands, diagnostics, new NullLogService(), NullApiDeprecationService);
|
||||
rpcProtocol.set(ExtHostContext.ExtHostLanguageFeatures, extHost);
|
||||
|
||||
mainThread = rpcProtocol.set(MainContext.MainThreadLanguageFeatures, inst.createInstance(MainThreadLanguageFeatures, rpcProtocol));
|
||||
@@ -589,7 +590,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None);
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, CancellationToken.None);
|
||||
assert.equal(actions.length, 2);
|
||||
const [first, second] = actions;
|
||||
assert.equal(first.title, 'Testing1');
|
||||
@@ -613,7 +614,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None);
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, CancellationToken.None);
|
||||
assert.equal(actions.length, 1);
|
||||
const [first] = actions;
|
||||
assert.equal(first.title, 'Testing1');
|
||||
@@ -636,7 +637,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None);
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, CancellationToken.None);
|
||||
assert.equal(actions.length, 1);
|
||||
});
|
||||
|
||||
@@ -654,7 +655,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None);
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, CancellationToken.None);
|
||||
assert.equal(actions.length, 1);
|
||||
});
|
||||
|
||||
@@ -758,8 +759,8 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
const value = await rename(model, new EditorPosition(1, 1), 'newName');
|
||||
// least relevant rename provider
|
||||
assert.equal(value.edits.length, 2);
|
||||
assert.equal((<modes.ResourceTextEdit>value.edits[0]).edits.length, 1);
|
||||
assert.equal((<modes.ResourceTextEdit>value.edits[1]).edits.length, 1);
|
||||
assert.equal((<modes.WorkspaceTextEdit>value.edits[0]).edits.length, 1);
|
||||
assert.equal((<modes.WorkspaceTextEdit>value.edits[1]).edits.length, 1);
|
||||
});
|
||||
|
||||
// --- parameter hints
|
||||
|
||||
@@ -16,7 +16,7 @@ import { NativeExtHostSearch } from 'vs/workbench/api/node/extHostSearch';
|
||||
import { Range } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { IFileMatch, IFileQuery, IPatternInfo, IRawFileMatch2, ISearchCompleteStats, ISearchQuery, ITextQuery, QueryType, resultIsMatch } from 'vs/workbench/services/search/common/search';
|
||||
import { TestRPCProtocol } from 'vs/workbench/test/electron-browser/api/testRPCProtocol';
|
||||
import * as vscode from 'vscode';
|
||||
import type * as vscode from 'vscode';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { URITransformerService } from 'vs/workbench/api/common/extHostUriTransformerService';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
|
||||
@@ -10,7 +10,7 @@ import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { SingleProxyRPCProtocol, TestRPCProtocol } from 'vs/workbench/test/electron-browser/api/testRPCProtocol';
|
||||
import { ExtHostEditors } from 'vs/workbench/api/common/extHostTextEditors';
|
||||
import { ResourceTextEdit } from 'vs/editor/common/modes';
|
||||
import { WorkspaceTextEdit } from 'vs/editor/common/modes';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
|
||||
suite('ExtHostTextEditors.applyWorkspaceEdit', () => {
|
||||
@@ -48,7 +48,7 @@ suite('ExtHostTextEditors.applyWorkspaceEdit', () => {
|
||||
edit.replace(resource, new extHostTypes.Range(0, 0, 0, 0), 'hello');
|
||||
await editors.applyWorkspaceEdit(edit);
|
||||
assert.equal(workspaceResourceEdits.edits.length, 1);
|
||||
assert.equal((<ResourceTextEdit>workspaceResourceEdits.edits[0]).modelVersionId, 1337);
|
||||
assert.equal((<WorkspaceTextEdit>workspaceResourceEdits.edits[0]).modelVersionId, 1337);
|
||||
});
|
||||
|
||||
test('does not use version id if document is not available', async () => {
|
||||
@@ -56,7 +56,7 @@ suite('ExtHostTextEditors.applyWorkspaceEdit', () => {
|
||||
edit.replace(URI.parse('foo:bar2'), new extHostTypes.Range(0, 0, 0, 0), 'hello');
|
||||
await editors.applyWorkspaceEdit(edit);
|
||||
assert.equal(workspaceResourceEdits.edits.length, 1);
|
||||
assert.ok(typeof (<ResourceTextEdit>workspaceResourceEdits.edits[0]).modelVersionId === 'undefined');
|
||||
assert.ok(typeof (<WorkspaceTextEdit>workspaceResourceEdits.edits[0]).modelVersionId === 'undefined');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -11,7 +11,7 @@ import { MainThreadWebviews } from 'vs/workbench/api/browser/mainThreadWebview';
|
||||
import { ExtHostWebviews } from 'vs/workbench/api/common/extHostWebview';
|
||||
import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import * as vscode from 'vscode';
|
||||
import type * as vscode from 'vscode';
|
||||
import { SingleProxyRPCProtocol } from './testRPCProtocol';
|
||||
|
||||
suite('ExtHostWebview', () => {
|
||||
|
||||
@@ -48,10 +48,10 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
codeEditorService = new TestCodeEditorService();
|
||||
textFileService = new class extends mock<ITextFileService>() {
|
||||
isDirty() { return false; }
|
||||
models = <any>{
|
||||
onModelSaved: Event.None,
|
||||
onModelReverted: Event.None,
|
||||
onModelDirty: Event.None,
|
||||
files = <any>{
|
||||
onDidSave: Event.None,
|
||||
onDidRevert: Event.None,
|
||||
onDidChangeDirty: Event.None
|
||||
};
|
||||
};
|
||||
const workbenchEditorService = new TestEditorService();
|
||||
@@ -61,7 +61,6 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
onAfterOperation = Event.None;
|
||||
};
|
||||
|
||||
/* tslint:disable */
|
||||
new MainThreadDocumentsAndEditors(
|
||||
SingleProxyRPCProtocol(new class extends mock<ExtHostDocumentsAndEditorsShape>() {
|
||||
$acceptDocumentsAndEditorsDelta(delta: IDocumentsAndEditorsDelta) { deltas.push(delta); }
|
||||
@@ -70,10 +69,8 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
textFileService,
|
||||
workbenchEditorService,
|
||||
codeEditorService,
|
||||
null!,
|
||||
fileService,
|
||||
null!,
|
||||
null!,
|
||||
editorGroupService,
|
||||
null!,
|
||||
new class extends mock<IPanelService>() implements IPanelService {
|
||||
@@ -86,7 +83,6 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
},
|
||||
TestEnvironmentService
|
||||
);
|
||||
/* tslint:enable */
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import { Position } from 'vs/editor/common/core/position';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService, TestContextService, TestTextResourcePropertiesService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { ResourceTextEdit } from 'vs/editor/common/modes';
|
||||
import { WorkspaceTextEdit } from 'vs/editor/common/modes';
|
||||
import { BulkEditService } from 'vs/workbench/services/bulkEdit/browser/bulkEditService';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { ITextModelService, IResolvedTextEditorModel } from 'vs/editor/common/services/resolverService';
|
||||
@@ -72,10 +72,10 @@ suite('MainThreadEditors', () => {
|
||||
copiedResources.set(source, target);
|
||||
return Promise.resolve(Object.create(null));
|
||||
}
|
||||
models = <any>{
|
||||
onModelSaved: Event.None,
|
||||
onModelReverted: Event.None,
|
||||
onModelDirty: Event.None,
|
||||
files = <any>{
|
||||
onDidSave: Event.None,
|
||||
onDidRevert: Event.None,
|
||||
onDidChangeDirty: Event.None
|
||||
};
|
||||
};
|
||||
const workbenchEditorService = new TestEditorService();
|
||||
@@ -112,10 +112,8 @@ suite('MainThreadEditors', () => {
|
||||
textFileService,
|
||||
workbenchEditorService,
|
||||
codeEditorService,
|
||||
null!,
|
||||
fileService,
|
||||
null!,
|
||||
null!,
|
||||
editorGroupService,
|
||||
bulkEditService,
|
||||
new class extends mock<IPanelService>() implements IPanelService {
|
||||
@@ -143,7 +141,7 @@ suite('MainThreadEditors', () => {
|
||||
|
||||
let model = modelService.createModel('something', null, resource);
|
||||
|
||||
let workspaceResourceEdit: ResourceTextEdit = {
|
||||
let workspaceResourceEdit: WorkspaceTextEdit = {
|
||||
resource: resource,
|
||||
modelVersionId: model.getVersionId(),
|
||||
edits: [{
|
||||
@@ -164,7 +162,7 @@ suite('MainThreadEditors', () => {
|
||||
|
||||
let model = modelService.createModel('something', null, resource);
|
||||
|
||||
let workspaceResourceEdit1: ResourceTextEdit = {
|
||||
let workspaceResourceEdit1: WorkspaceTextEdit = {
|
||||
resource: resource,
|
||||
modelVersionId: model.getVersionId(),
|
||||
edits: [{
|
||||
@@ -172,7 +170,7 @@ suite('MainThreadEditors', () => {
|
||||
range: new Range(1, 1, 1, 1)
|
||||
}]
|
||||
};
|
||||
let workspaceResourceEdit2: ResourceTextEdit = {
|
||||
let workspaceResourceEdit2: WorkspaceTextEdit = {
|
||||
resource: resource,
|
||||
modelVersionId: model.getVersionId(),
|
||||
edits: [{
|
||||
|
||||
@@ -33,7 +33,7 @@ suite('MainThreadSaveParticipant', function () {
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
(<TextFileEditorModelManager>accessor.textFileService.models).clear();
|
||||
(<TextFileEditorModelManager>accessor.textFileService.files).dispose();
|
||||
TextFileEditorModel.setSaveParticipant(null); // reset any set participant
|
||||
});
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Timer {
|
||||
}
|
||||
}
|
||||
|
||||
declare var __dirname: string;
|
||||
// declare var __dirname: string;
|
||||
|
||||
// Checkout sources to run against:
|
||||
// git clone --separate-git-dir=testGit --no-checkout --single-branch https://chromium.googlesource.com/chromium/src testWorkspace
|
||||
|
||||
@@ -36,7 +36,7 @@ import { ITextResourcePropertiesService } from 'vs/editor/common/services/textRe
|
||||
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
|
||||
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
|
||||
declare var __dirname: string;
|
||||
// declare var __dirname: string;
|
||||
|
||||
// Checkout sources to run against:
|
||||
// git clone --separate-git-dir=testGit --no-checkout --single-branch https://chromium.googlesource.com/chromium/src testWorkspace
|
||||
|
||||
@@ -190,50 +190,40 @@ export class TestContextService implements IWorkspaceContextService {
|
||||
}
|
||||
|
||||
export class TestTextFileService extends NativeTextFileService {
|
||||
cleanupBackupsBeforeShutdownCalled!: boolean;
|
||||
|
||||
private promptPath!: URI;
|
||||
private resolveTextContentError!: FileOperationError | null;
|
||||
|
||||
constructor(
|
||||
@IWorkspaceContextService contextService: IWorkspaceContextService,
|
||||
@IFileService protected fileService: IFileService,
|
||||
@IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorService,
|
||||
@ILifecycleService lifecycleService: ILifecycleService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IModeService modeService: IModeService,
|
||||
@IModelService modelService: IModelService,
|
||||
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IBackupFileService backupFileService: IBackupFileService,
|
||||
@IHistoryService historyService: IHistoryService,
|
||||
@IDialogService dialogService: IDialogService,
|
||||
@IFileDialogService fileDialogService: IFileDialogService,
|
||||
@IEditorService editorService: IEditorService,
|
||||
@ITextResourceConfigurationService textResourceConfigurationService: ITextResourceConfigurationService,
|
||||
@IElectronService electronService: IElectronService,
|
||||
@IProductService productService: IProductService,
|
||||
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService
|
||||
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService,
|
||||
@ITextModelService textModelService: ITextModelService
|
||||
) {
|
||||
super(
|
||||
contextService,
|
||||
fileService,
|
||||
untitledTextEditorService,
|
||||
lifecycleService,
|
||||
instantiationService,
|
||||
modeService,
|
||||
modelService,
|
||||
environmentService,
|
||||
notificationService,
|
||||
backupFileService,
|
||||
historyService,
|
||||
dialogService,
|
||||
fileDialogService,
|
||||
editorService,
|
||||
textResourceConfigurationService,
|
||||
electronService,
|
||||
productService,
|
||||
filesConfigurationService
|
||||
filesConfigurationService,
|
||||
textModelService
|
||||
);
|
||||
}
|
||||
|
||||
@@ -269,11 +259,6 @@ export class TestTextFileService extends NativeTextFileService {
|
||||
promptForPath(_resource: URI, _defaultPath: URI): Promise<URI> {
|
||||
return Promise.resolve(this.promptPath);
|
||||
}
|
||||
|
||||
protected cleanupBackupsBeforeShutdown(): Promise<void> {
|
||||
this.cleanupBackupsBeforeShutdownCalled = true;
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
export interface ITestInstantiationService extends IInstantiationService {
|
||||
@@ -426,7 +411,7 @@ export class TestFileDialogService implements IFileDialogService {
|
||||
pickWorkspaceAndOpen(_options: IPickAndOpenOptions): Promise<any> {
|
||||
return Promise.resolve(0);
|
||||
}
|
||||
pickFileToSave(_options: ISaveDialogOptions): Promise<URI | undefined> {
|
||||
pickFileToSave(defaultUri: URI, availableFileSystems?: string[]): Promise<URI | undefined> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
showSaveDialog(_options: ISaveDialogOptions): Promise<URI | undefined> {
|
||||
@@ -905,6 +890,7 @@ export class TestEditorService implements EditorServiceImpl {
|
||||
|
||||
activeControl!: IVisibleEditor;
|
||||
activeTextEditorWidget: any;
|
||||
activeTextEditorMode: any;
|
||||
activeEditor!: IEditorInput;
|
||||
editors: ReadonlyArray<IEditorInput> = [];
|
||||
mostRecentlyActiveEditors: ReadonlyArray<IEditorIdentifier> = [];
|
||||
@@ -1222,7 +1208,11 @@ export class TestBackupFileService implements IBackupFileService {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
didDiscardAllWorkspaceBackups = false;
|
||||
|
||||
discardAllWorkspaceBackups(): Promise<void> {
|
||||
this.didDiscardAllWorkspaceBackups = true;
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user