Update to VS Code 1.52.1

This commit is contained in:
Asher
2021-02-09 16:08:37 +00:00
1351 changed files with 56560 additions and 38990 deletions

View File

@@ -28,7 +28,7 @@ import 'vs/workbench/contrib/search/browser/search.contribution';
import { NullLogService } from 'vs/platform/log/common/log';
import { ITextModel } from 'vs/editor/common/model';
import { nullExtensionDescription, IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { dispose } from 'vs/base/common/lifecycle';
import { dispose, ImmortalReference } from 'vs/base/common/lifecycle';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
import { mock } from 'vs/base/test/common/mock';
import { NullApiDeprecationService } from 'vs/workbench/api/common/extHostApiDeprecationService';
@@ -48,6 +48,7 @@ import 'vs/editor/contrib/parameterHints/provideSignatureHelp';
import 'vs/editor/contrib/smartSelect/smartSelect';
import 'vs/editor/contrib/suggest/suggest';
import 'vs/editor/contrib/rename/rename';
import { IResolvedTextEditorModel, ITextModelService } from 'vs/editor/common/services/resolverService';
const defaultSelector = { scheme: 'far' };
const model: ITextModel = createTextModel(
@@ -108,6 +109,13 @@ suite('ExtHostLanguageFeatureCommands', function () {
services.set(IModelService, new class extends mock<IModelService>() {
getModel() { return model; }
});
services.set(ITextModelService, new class extends mock<ITextModelService>() {
async createModelReference() {
return new ImmortalReference<IResolvedTextEditorModel>(new class extends mock<IResolvedTextEditorModel>() {
textEditorModel = model;
});
}
});
services.set(IEditorWorkerService, new class extends mock<IEditorWorkerService>() {
async computeMoreMinimalEdits(_uri: any, edits: any) {
return edits || undefined;

View File

@@ -15,6 +15,9 @@ import { IWorkspaceFolder, WorkspaceFolder } from 'vs/platform/workspace/common/
import { ConfigurationTarget, IConfigurationModel, IConfigurationChange } from 'vs/platform/configuration/common/configuration';
import { NullLogService } from 'vs/platform/log/common/log';
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
import { IExtHostFileSystemInfo } from 'vs/workbench/api/common/extHostFileSystemInfo';
import { FileSystemProviderCapabilities } from 'vs/platform/files/common/files';
import { isLinux } from 'vs/base/common/platform';
suite('ExtHostConfiguration', function () {
@@ -27,7 +30,7 @@ suite('ExtHostConfiguration', function () {
}
function createExtHostWorkspace(): ExtHostWorkspace {
return new ExtHostWorkspace(new TestRPCProtocol(), new class extends mock<IExtHostInitDataService>() { }, new NullLogService());
return new ExtHostWorkspace(new TestRPCProtocol(), new class extends mock<IExtHostInitDataService>() { }, new class extends mock<IExtHostFileSystemInfo>() { getCapabilities() { return isLinux ? FileSystemProviderCapabilities.PathCaseSensitive : undefined; } }, new NullLogService());
}
function createExtHostConfiguration(contents: any = Object.create(null), shape?: MainThreadConfigurationShape) {

View File

@@ -6,7 +6,6 @@
import * as assert from 'assert';
import { timeout } from 'vs/base/common/async';
import { CancellationToken } from 'vs/base/common/cancellation';
import { Event } from 'vs/base/common/event';
import { URI } from 'vs/base/common/uri';
import { mock } from 'vs/base/test/common/mock';
import { NullLogService } from 'vs/platform/log/common/log';
@@ -47,8 +46,8 @@ suite('ExtHostDecorations', function () {
let calledB = false;
// never returns
extHostDecorations.registerDecorationProvider({
onDidChange: Event.None,
extHostDecorations.registerFileDecorationProvider({
provideFileDecoration() {
calledA = true;
return new Promise(() => { });
@@ -56,8 +55,8 @@ suite('ExtHostDecorations', function () {
}, nullExtensionDescription.identifier);
// always returns
extHostDecorations.registerDecorationProvider({
onDidChange: Event.None,
extHostDecorations.registerFileDecorationProvider({
provideFileDecoration() {
calledB = true;
return new Promise(resolve => resolve({ badge: 'H', tooltip: 'Hello' }));

View File

@@ -0,0 +1,310 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { MirroredTestCollection, OwnedTestCollection, SingleUseTestCollection } from 'vs/workbench/api/common/extHostTesting';
import * as convert from 'vs/workbench/api/common/extHostTypeConverters';
import { TestRunState, TestState } from 'vs/workbench/api/common/extHostTypes';
import { TestDiffOpType, TestsDiff } from 'vs/workbench/contrib/testing/common/testCollection';
import { TestChangeEvent, TestItem } from 'vscode';
const stubTest = (label: string): TestItem => ({
label,
location: undefined,
state: new TestState(TestRunState.Unset),
debuggable: true,
runnable: true,
description: ''
});
const simplify = (item: TestItem) => {
if ('toJSON' in item) {
item = (item as any).toJSON();
}
return { ...item, children: undefined };
};
const assertTreesEqual = (a: Readonly<TestItem>, b: Readonly<TestItem>) => {
assert.deepStrictEqual(simplify(a), simplify(b));
const aChildren = (a.children ?? []).sort();
const bChildren = (b.children ?? []).sort();
assert.strictEqual(aChildren.length, bChildren.length, `expected ${a.label}.children.length == ${b.label}.children.length`);
aChildren.forEach((_, i) => assertTreesEqual(aChildren[i], bChildren[i]));
};
const assertTreeListEqual = (a: ReadonlyArray<Readonly<TestItem>>, b: ReadonlyArray<Readonly<TestItem>>) => {
assert.strictEqual(a.length, b.length, `expected a.length == n.length`);
a.forEach((_, i) => assertTreesEqual(a[i], b[i]));
};
const stubNestedTests = () => ({
...stubTest('root'),
children: [
{ ...stubTest('a'), children: [stubTest('aa'), stubTest('ab')] },
stubTest('b'),
]
});
class TestOwnedTestCollection extends OwnedTestCollection {
public get idToInternal() {
return this.testIdToInternal;
}
public createForHierarchy(publishDiff: (diff: TestsDiff) => void = () => undefined) {
return new TestSingleUseCollection(this.testIdToInternal, publishDiff);
}
}
class TestSingleUseCollection extends SingleUseTestCollection {
private idCounter = 0;
public get itemToInternal() {
return this.testItemToInternal;
}
public get currentDiff() {
return this.diff;
}
protected getId() {
return String(this.idCounter++);
}
public setDiff(diff: TestsDiff) {
this.diff = diff;
}
}
class TestMirroredCollection extends MirroredTestCollection {
public changeEvent!: TestChangeEvent;
constructor() {
super();
this.onDidChangeTests(evt => this.changeEvent = evt);
}
public get length() {
return this.items.size;
}
}
suite('ExtHost Testing', () => {
let single: TestSingleUseCollection;
let owned: TestOwnedTestCollection;
setup(() => {
owned = new TestOwnedTestCollection();
single = owned.createForHierarchy(d => single.setDiff(d /* don't clear during testing */));
});
teardown(() => {
single.dispose();
assert.deepEqual(owned.idToInternal.size, 0, 'expected owned ids to be empty after dispose');
});
suite('OwnedTestCollection', () => {
test('adds a root recursively', () => {
const tests = stubNestedTests();
single.addRoot(tests, 'pid');
assert.deepStrictEqual(single.collectDiff(), [
[TestDiffOpType.Add, { id: '0', providerId: 'pid', parent: null, item: convert.TestItem.from(stubTest('root')) }],
[TestDiffOpType.Add, { id: '1', providerId: 'pid', parent: '0', item: convert.TestItem.from(stubTest('a')) }],
[TestDiffOpType.Add, { id: '2', providerId: 'pid', parent: '1', item: convert.TestItem.from(stubTest('aa')) }],
[TestDiffOpType.Add, { id: '3', providerId: 'pid', parent: '1', item: convert.TestItem.from(stubTest('ab')) }],
[TestDiffOpType.Add, { id: '4', providerId: 'pid', parent: '0', item: convert.TestItem.from(stubTest('b')) }],
]);
});
test('no-ops if items not changed', () => {
const tests = stubNestedTests();
single.addRoot(tests, 'pid');
single.collectDiff();
assert.deepStrictEqual(single.collectDiff(), []);
});
test('watches property mutations', () => {
const tests = stubNestedTests();
single.addRoot(tests, 'pid');
single.collectDiff();
tests.children![0].description = 'Hello world'; /* item a */
single.onItemChange(tests, 'pid');
assert.deepStrictEqual(single.collectDiff(), [
[TestDiffOpType.Update, { id: '1', parent: '0', providerId: 'pid', item: convert.TestItem.from({ ...stubTest('a'), description: 'Hello world' }) }],
]);
single.onItemChange(tests, 'pid');
assert.deepStrictEqual(single.collectDiff(), []);
});
test('removes children', () => {
const tests = stubNestedTests();
single.addRoot(tests, 'pid');
single.collectDiff();
tests.children!.splice(0, 1);
single.onItemChange(tests, 'pid');
assert.deepStrictEqual(single.collectDiff(), [
[TestDiffOpType.Remove, '1'],
]);
assert.deepStrictEqual([...owned.idToInternal.keys()].sort(), ['0', '4']);
assert.strictEqual(single.itemToInternal.size, 2);
});
test('adds new children', () => {
const tests = stubNestedTests();
single.addRoot(tests, 'pid');
single.collectDiff();
const child = stubTest('ac');
tests.children![0].children!.push(child);
single.onItemChange(tests, 'pid');
assert.deepStrictEqual(single.collectDiff(), [
[TestDiffOpType.Add, { id: '5', providerId: 'pid', parent: '1', item: convert.TestItem.from(child) }],
]);
assert.deepStrictEqual([...owned.idToInternal.keys()].sort(), ['0', '1', '2', '3', '4', '5']);
assert.strictEqual(single.itemToInternal.size, 6);
});
});
suite('MirroredTestCollection', () => {
let m: TestMirroredCollection;
setup(() => m = new TestMirroredCollection());
test('mirrors creation of the root', () => {
const tests = stubNestedTests();
single.addRoot(tests, 'pid');
m.apply(single.collectDiff());
assertTreesEqual(m.rootTestItems[0], owned.getTestById('0')!.actual);
assert.strictEqual(m.length, single.itemToInternal.size);
});
test('mirrors node deletion', () => {
const tests = stubNestedTests();
single.addRoot(tests, 'pid');
m.apply(single.collectDiff());
tests.children!.splice(0, 1);
single.onItemChange(tests, 'pid');
m.apply(single.collectDiff());
assertTreesEqual(m.rootTestItems[0], owned.getTestById('0')!.actual);
assert.strictEqual(m.length, single.itemToInternal.size);
});
test('mirrors node addition', () => {
const tests = stubNestedTests();
single.addRoot(tests, 'pid');
m.apply(single.collectDiff());
tests.children![0].children!.push(stubTest('ac'));
single.onItemChange(tests, 'pid');
m.apply(single.collectDiff());
assertTreesEqual(m.rootTestItems[0], owned.getTestById('0')!.actual);
assert.strictEqual(m.length, single.itemToInternal.size);
});
test('mirrors node update', () => {
const tests = stubNestedTests();
single.addRoot(tests, 'pid');
m.apply(single.collectDiff());
tests.children![0].description = 'Hello world'; /* item a */
single.onItemChange(tests, 'pid');
m.apply(single.collectDiff());
assertTreesEqual(m.rootTestItems[0], owned.getTestById('0')!.actual);
});
suite('MirroredChangeCollector', () => {
let tests = stubNestedTests();
setup(() => {
tests = stubNestedTests();
single.addRoot(tests, 'pid');
m.apply(single.collectDiff());
});
test('creates change for root', () => {
assert.deepStrictEqual(m.changeEvent.commonChangeAncestor, null);
assertTreeListEqual(m.changeEvent.added, [
tests,
tests.children[0],
tests.children![0].children![0],
tests.children![0].children![1],
tests.children[1],
]);
assertTreeListEqual(m.changeEvent.removed, []);
assertTreeListEqual(m.changeEvent.updated, []);
});
test('creates change for delete', () => {
const rm = tests.children.shift()!;
single.onItemChange(tests, 'pid');
m.apply(single.collectDiff());
assertTreesEqual(m.changeEvent.commonChangeAncestor!, tests);
assertTreeListEqual(m.changeEvent.added, []);
assertTreeListEqual(m.changeEvent.removed, [
{ ...rm, children: [] },
{ ...rm.children![0], children: [] },
{ ...rm.children![1], children: [] },
]);
assertTreeListEqual(m.changeEvent.updated, []);
});
test('creates change for update', () => {
tests.children[0].label = 'updated!';
single.onItemChange(tests, 'pid');
m.apply(single.collectDiff());
assert.deepStrictEqual(m.changeEvent.commonChangeAncestor?.label, 'updated!');
assertTreeListEqual(m.changeEvent.added, []);
assertTreeListEqual(m.changeEvent.removed, []);
assertTreeListEqual(m.changeEvent.updated, [tests.children[0]]);
});
test('is a no-op if a node is added and removed', () => {
const nested = stubNestedTests();
tests.children.push(nested);
single.onItemChange(tests, 'pid');
tests.children.pop();
single.onItemChange(tests, 'pid');
const previousEvent = m.changeEvent;
m.apply(single.collectDiff());
assert.strictEqual(m.changeEvent, previousEvent);
});
test('is a single-op if a node is added and changed', () => {
const child = stubTest('c');
tests.children.push(child);
single.onItemChange(tests, 'pid');
child.label = 'd';
single.onItemChange(tests, 'pid');
m.apply(single.collectDiff());
assert.strictEqual(m.changeEvent.commonChangeAncestor?.label, 'root');
assertTreeListEqual(m.changeEvent.added, [child]);
assertTreeListEqual(m.changeEvent.removed, []);
assertTreeListEqual(m.changeEvent.updated, []);
});
test('gets the common ancestor (1)', () => {
tests.children![0].children![0].label = 'za';
tests.children![0].children![1].label = 'zb';
single.onItemChange(tests, 'pid');
m.apply(single.collectDiff());
assert.strictEqual(m.changeEvent.commonChangeAncestor?.label, 'a');
});
test('gets the common ancestor (2)', () => {
tests.children![0].children![0].label = 'za';
tests.children![1].label = 'ab';
single.onItemChange(tests, 'pid');
m.apply(single.collectDiff());
assert.strictEqual(m.changeEvent.commonChangeAncestor?.label, 'root');
});
});
});
});

View File

@@ -488,41 +488,53 @@ suite('ExtHostTreeView', function () {
test('reveal will return empty array for root element', () => {
const revealTarget = sinon.spy(target, '$reveal');
const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription);
const expected = {
item:
{ handle: '0/0:a', label: { label: 'a' }, collapsibleState: TreeItemCollapsibleState.Collapsed },
parentChain: []
};
return treeView.reveal({ key: 'a' })
.then(() => {
assert.ok(revealTarget.calledOnce);
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepEqual({ handle: '0/0:a', label: { label: 'a' }, collapsibleState: TreeItemCollapsibleState.Collapsed }, removeUnsetKeys(revealTarget.args[0][1]));
assert.deepEqual([], revealTarget.args[0][2]);
assert.deepEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][3]);
assert.deepEqual(expected, removeUnsetKeys(revealTarget.args[0][1]));
assert.deepEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][2]);
});
});
test('reveal will return parents array for an element when hierarchy is not loaded', () => {
const revealTarget = sinon.spy(target, '$reveal');
const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription);
const expected = {
item: { handle: '0/0:a/0:aa', label: { label: 'aa' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:a' },
parentChain: [{ handle: '0/0:a', label: { label: 'a' }, collapsibleState: TreeItemCollapsibleState.Collapsed }]
};
return treeView.reveal({ key: 'aa' })
.then(() => {
assert.ok(revealTarget.calledOnce);
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepEqual({ handle: '0/0:a/0:aa', label: { label: 'aa' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:a' }, removeUnsetKeys(revealTarget.args[0][1]));
assert.deepEqual([{ handle: '0/0:a', label: { label: 'a' }, collapsibleState: TreeItemCollapsibleState.Collapsed }], (<Array<any>>revealTarget.args[0][2]).map(arg => removeUnsetKeys(arg)));
assert.deepEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][3]);
assert.deepEqual(expected.item, removeUnsetKeys(revealTarget.args[0][1].item));
assert.deepEqual(expected.parentChain, (<Array<any>>(revealTarget.args[0][1].parentChain)).map(arg => removeUnsetKeys(arg)));
assert.deepEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][2]);
});
});
test('reveal will return parents array for an element when hierarchy is loaded', () => {
const revealTarget = sinon.spy(target, '$reveal');
const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription);
const expected = {
item: { handle: '0/0:a/0:aa', label: { label: 'aa' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:a' },
parentChain: [{ handle: '0/0:a', label: { label: 'a' }, collapsibleState: TreeItemCollapsibleState.Collapsed }]
};
return testObject.$getChildren('treeDataProvider')
.then(() => testObject.$getChildren('treeDataProvider', '0/0:a'))
.then(() => treeView.reveal({ key: 'aa' })
.then(() => {
assert.ok(revealTarget.calledOnce);
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepEqual({ handle: '0/0:a/0:aa', label: { label: 'aa' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:a' }, removeUnsetKeys(revealTarget.args[0][1]));
assert.deepEqual([{ handle: '0/0:a', label: { label: 'a' }, collapsibleState: TreeItemCollapsibleState.Collapsed }], (<Array<any>>revealTarget.args[0][2]).map(arg => removeUnsetKeys(arg)));
assert.deepEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][3]);
assert.deepEqual(expected.item, removeUnsetKeys(revealTarget.args[0][1].item));
assert.deepEqual(expected.parentChain, (<Array<any>>(revealTarget.args[0][1].parentChain)).map(arg => removeUnsetKeys(arg)));
assert.deepEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][2]);
}));
});
@@ -536,22 +548,30 @@ suite('ExtHostTreeView', function () {
};
const revealTarget = sinon.spy(target, '$reveal');
const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription);
const expected = {
item: { handle: '0/0:b/0:ba/0:bac', label: { label: 'bac' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:b/0:ba' },
parentChain: [
{ handle: '0/0:b', label: { label: 'b' }, collapsibleState: TreeItemCollapsibleState.Collapsed },
{ handle: '0/0:b/0:ba', label: { label: 'ba' }, collapsibleState: TreeItemCollapsibleState.Collapsed, parentHandle: '0/0:b' }
]
};
return treeView.reveal({ key: 'bac' }, { select: false, focus: false, expand: false })
.then(() => {
assert.ok(revealTarget.calledOnce);
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepEqual({ handle: '0/0:b/0:ba/0:bac', label: { label: 'bac' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:b/0:ba' }, removeUnsetKeys(revealTarget.args[0][1]));
assert.deepEqual([
{ handle: '0/0:b', label: { label: 'b' }, collapsibleState: TreeItemCollapsibleState.Collapsed },
{ handle: '0/0:b/0:ba', label: { label: 'ba' }, collapsibleState: TreeItemCollapsibleState.Collapsed, parentHandle: '0/0:b' }
], (<Array<any>>revealTarget.args[0][2]).map(arg => removeUnsetKeys(arg)));
assert.deepEqual({ select: false, focus: false, expand: false }, revealTarget.args[0][3]);
assert.deepEqual(expected.item, removeUnsetKeys(revealTarget.args[0][1].item));
assert.deepEqual(expected.parentChain, (<Array<any>>(revealTarget.args[0][1].parentChain)).map(arg => removeUnsetKeys(arg)));
assert.deepEqual({ select: false, focus: false, expand: false }, revealTarget.args[0][2]);
});
});
test('reveal after first udpate', () => {
const revealTarget = sinon.spy(target, '$reveal');
const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription);
const expected = {
item: { handle: '0/0:a/0:ac', label: { label: 'ac' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:a' },
parentChain: [{ handle: '0/0:a', label: { label: 'a' }, collapsibleState: TreeItemCollapsibleState.Collapsed }]
};
return loadCompleteTree('treeDataProvider')
.then(() => {
tree = {
@@ -570,9 +590,9 @@ suite('ExtHostTreeView', function () {
.then(() => {
assert.ok(revealTarget.calledOnce);
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepEqual({ handle: '0/0:a/0:ac', label: { label: 'ac' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:a' }, removeUnsetKeys(revealTarget.args[0][1]));
assert.deepEqual([{ handle: '0/0:a', label: { label: 'a' }, collapsibleState: TreeItemCollapsibleState.Collapsed }], (<Array<any>>revealTarget.args[0][2]).map(arg => removeUnsetKeys(arg)));
assert.deepEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][3]);
assert.deepEqual(expected.item, removeUnsetKeys(revealTarget.args[0][1].item));
assert.deepEqual(expected.parentChain, (<Array<any>>(revealTarget.args[0][1].parentChain)).map(arg => removeUnsetKeys(arg)));
assert.deepEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][2]);
});
});
});

View File

@@ -5,10 +5,9 @@
import * as assert from 'assert';
import { MarkdownString, LogLevel } from 'vs/workbench/api/common/extHostTypeConverters';
import { MarkdownString } from 'vs/workbench/api/common/extHostTypeConverters';
import { isEmptyObject } from 'vs/base/common/types';
import { forEach } from 'vs/base/common/collections';
import * as types from 'vs/workbench/api/common/extHostTypes';
import { LogLevel as _MainLogLevel } from 'vs/platform/log/common/log';
import { URI } from 'vs/base/common/uri';
@@ -82,14 +81,4 @@ suite('ExtHostTypeConverter', function () {
}
});
});
test('LogLevel', () => {
assert.equal(LogLevel.from(types.LogLevel.Error), _MainLogLevel.Error);
assert.equal(LogLevel.from(types.LogLevel.Info), _MainLogLevel.Info);
assert.equal(LogLevel.from(types.LogLevel.Off), _MainLogLevel.Off);
assert.equal(LogLevel.to(_MainLogLevel.Error), types.LogLevel.Error);
assert.equal(LogLevel.to(_MainLogLevel.Info), types.LogLevel.Info);
assert.equal(LogLevel.to(_MainLogLevel.Off), types.LogLevel.Off);
});
});

View File

@@ -642,4 +642,10 @@ suite('ExtHostTypes', function () {
1, 0, 3, 3, (1 << 2) | (1 << 4)
]);
});
test('Markdown codeblock rendering is swapped #111604', function () {
const md = new types.MarkdownString().appendCodeblock('<img src=0 onerror="alert(1)">', 'html');
assert.deepEqual(md.value, '\n```html\n<img src=0 onerror="alert(1)">\n```\n');
});
});

View File

@@ -14,7 +14,7 @@ import { NullApiDeprecationService } from 'vs/workbench/api/common/extHostApiDep
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { ExtHostWebviews } from 'vs/workbench/api/common/extHostWebview';
import { ExtHostWebviewPanels } from 'vs/workbench/api/common/extHostWebviewPanels';
import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor';
import { EditorGroupColumn } from 'vs/workbench/common/editor';
import type * as vscode from 'vscode';
import { SingleProxyRPCProtocol } from './testRPCProtocol';
@@ -53,7 +53,7 @@ suite('ExtHostWebview', () => {
const serializerARegistration = extHostWebviewPanels.registerWebviewPanelSerializer(extension, viewType, serializerA);
await extHostWebviewPanels.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorViewColumn, {});
await extHostWebviewPanels.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorGroupColumn, {});
assert.strictEqual(lastInvokedDeserializer, serializerA);
assert.throws(
@@ -64,7 +64,7 @@ suite('ExtHostWebview', () => {
extHostWebviewPanels.registerWebviewPanelSerializer(extension, viewType, serializerB);
await extHostWebviewPanels.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorViewColumn, {});
await extHostWebviewPanels.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorGroupColumn, {});
assert.strictEqual(lastInvokedDeserializer, serializerB);
});

View File

@@ -20,13 +20,16 @@ import { ExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
import { ITextQueryBuilderOptions } from 'vs/workbench/contrib/search/common/queryBuilder';
import { IPatternInfo } from 'vs/workbench/services/search/common/search';
import { isWindows } from 'vs/base/common/platform';
import { isLinux, isWindows } from 'vs/base/common/platform';
import { IExtHostFileSystemInfo } from 'vs/workbench/api/common/extHostFileSystemInfo';
import { FileSystemProviderCapabilities } from 'vs/platform/files/common/files';
function createExtHostWorkspace(mainContext: IMainContext, data: IWorkspaceData, logService: ILogService): ExtHostWorkspace {
const result = new ExtHostWorkspace(
new ExtHostRpcService(mainContext),
new class extends mock<IExtHostInitDataService>() { workspace = data; },
logService
new class extends mock<IExtHostFileSystemInfo>() { getCapabilities() { return isLinux ? FileSystemProviderCapabilities.PathCaseSensitive : undefined; } },
logService,
);
result.$initializeWorkspace(data);
return result;
@@ -602,7 +605,7 @@ suite('ExtHostWorkspace', function () {
});
});
test('findFiles - RelativePattern include', () => {
function testFindFilesInclude(pattern: RelativePattern) {
const root = '/project/foo';
const rpcProtocol = new TestRPCProtocol();
@@ -611,16 +614,24 @@ suite('ExtHostWorkspace', function () {
$startFileSearch(includePattern: string, _includeFolder: UriComponents | null, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | null> {
mainThreadCalled = true;
assert.equal(includePattern, 'glob/**');
assert.deepEqual(_includeFolder, URI.file('/other/folder').toJSON());
assert.deepEqual(_includeFolder ? URI.from(_includeFolder).toJSON() : null, URI.file('/other/folder').toJSON());
assert.equal(excludePatternOrDisregardExcludes, null);
return Promise.resolve(null);
}
});
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService());
return ws.findFiles(new RelativePattern('/other/folder', 'glob/**'), undefined, 10, new ExtensionIdentifier('test')).then(() => {
return ws.findFiles(pattern, undefined, 10, new ExtensionIdentifier('test')).then(() => {
assert(mainThreadCalled, 'mainThreadCalled');
});
}
test('findFiles - RelativePattern include (string)', () => {
return testFindFilesInclude(new RelativePattern('/other/folder', 'glob/**'));
});
test('findFiles - RelativePattern include (URI)', () => {
return testFindFilesInclude(new RelativePattern(URI.file('/other/folder'), 'glob/**'));
});
test('findFiles - no excludes', () => {

View File

@@ -15,8 +15,8 @@ import { TestNotificationService } from 'vs/platform/notification/test/common/te
import { Registry } from 'vs/platform/registry/common/platform';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { CustomTreeView } from 'vs/workbench/contrib/views/browser/treeView';
import { ViewDescriptorService } from 'vs/workbench/services/views/browser/viewDescriptorService';
import { CustomTreeView } from 'vs/workbench/browser/parts/views/treeView';
suite('MainThreadHostTreeView', function () {
const testTreeViewId = 'testTreeView';

View File

@@ -9,7 +9,7 @@ import * as Types from 'vs/base/common/types';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
import { append, $, hide } from 'vs/base/browser/dom';
import { TestLayoutService } from 'vs/workbench/test/browser/workbenchTestServices';
import { StorageScope } from 'vs/platform/storage/common/storage';
import { StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
class SimplePart extends Part {
@@ -44,8 +44,8 @@ class MyPart extends SimplePart {
return super.createContentArea(parent)!;
}
getMemento(scope: StorageScope) {
return super.getMemento(scope);
getMemento(scope: StorageScope, target: StorageTarget) {
return super.getMemento(scope, target);
}
saveState(): void {
@@ -123,7 +123,7 @@ suite('Workbench parts', () => {
assert.strictEqual(part.getId(), 'myPart');
// Memento
let memento = part.getMemento(StorageScope.GLOBAL) as any;
let memento = part.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE) as any;
assert(memento);
memento.foo = 'bar';
memento.bar = [1, 2, 3];
@@ -133,7 +133,7 @@ suite('Workbench parts', () => {
// Re-Create to assert memento contents
part = new MyPart(b);
memento = part.getMemento(StorageScope.GLOBAL);
memento = part.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert(memento);
assert.strictEqual(memento.foo, 'bar');
assert.strictEqual(memento.bar.length, 3);
@@ -144,7 +144,7 @@ suite('Workbench parts', () => {
part.saveState();
part = new MyPart(b);
memento = part.getMemento(StorageScope.GLOBAL);
memento = part.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert(memento);
assert.strictEqual(Types.isEmptyObject(memento), true);
});

View File

@@ -5,11 +5,12 @@
import * as assert from 'assert';
import { URI } from 'vs/base/common/uri';
import { Workspace, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { EditorBreadcrumbsModel, FileElement } from 'vs/workbench/browser/parts/editor/breadcrumbsModel';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { FileKind } from 'vs/platform/files/common/files';
import { TestContextService } from 'vs/workbench/test/common/workbenchTestServices';
import { Workspace } from 'vs/platform/workspace/test/common/testWorkspace';
suite('Breadcrumb Model', function () {

View File

@@ -75,7 +75,7 @@ suite('Workbench editor', () => {
assert.equal(EditorResourceAccessor.getOriginalUri(file, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.resource.toString());
assert.ok(!EditorResourceAccessor.getOriginalUri(file, { filterByScheme: Schemas.untitled }));
const diffEditorInput = new DiffEditorInput('name', 'description', untitled, file);
const diffEditorInput = instantiationService.createInstance(DiffEditorInput, 'name', 'description', untitled, file, undefined);
assert.ok(!EditorResourceAccessor.getCanonicalUri(diffEditorInput));
assert.ok(!EditorResourceAccessor.getCanonicalUri(diffEditorInput, { filterByScheme: Schemas.file }));

View File

@@ -37,7 +37,7 @@ suite('Workbench editor model', () => {
let input = instantiationService.createInstance(ResourceEditorInput, URI.from({ scheme: 'test', authority: null!, path: 'thePath' }), 'name', 'description', undefined);
let otherInput = instantiationService.createInstance(ResourceEditorInput, URI.from({ scheme: 'test', authority: null!, path: 'thePath' }), 'name2', 'description', undefined);
let diffInput = new DiffEditorInput('name', 'description', input, otherInput);
let diffInput = instantiationService.createInstance(DiffEditorInput, 'name', 'description', input, otherInput, undefined);
let model = await diffInput.resolve() as TextDiffEditorModel;

View File

@@ -7,7 +7,7 @@ import * as assert from 'assert';
import { EditorGroup, ISerializedEditorGroup, EditorCloseEvent } from 'vs/workbench/common/editor/editorGroup';
import { Extensions as EditorExtensions, IEditorInputFactoryRegistry, EditorInput, IFileEditorInput, IEditorInputFactory, CloseDirection, EditorsOrder } from 'vs/workbench/common/editor';
import { URI } from 'vs/base/common/uri';
import { TestLifecycleService } from 'vs/workbench/test/browser/workbenchTestServices';
import { TestLifecycleService, workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -157,6 +157,8 @@ class TestFileEditorInput extends EditorInput implements IFileEditorInput {
}
getTypeId() { return 'testFileEditorInputForGroups'; }
resolve(): Promise<IEditorModel> { return Promise.resolve(null!); }
setPreferredName(name: string): void { }
setPreferredDescription(description: string): void { }
setPreferredResource(resource: URI): void { }
setEncoding(encoding: string) { }
getEncoding() { return undefined; }
@@ -269,12 +271,13 @@ suite('Workbench editor groups', () => {
test('contains()', function () {
const group = createGroup();
const instantiationService = workbenchInstantiationService();
const input1 = input();
const input2 = input();
const diffInput1 = new DiffEditorInput('name', 'description', input1, input2);
const diffInput2 = new DiffEditorInput('name', 'description', input2, input1);
const diffInput1 = instantiationService.createInstance(DiffEditorInput, 'name', 'description', input1, input2, undefined);
const diffInput2 = instantiationService.createInstance(DiffEditorInput, 'name', 'description', input2, input1, undefined);
group.openEditor(input1, { pinned: true, active: true });

View File

@@ -6,6 +6,7 @@
import * as assert from 'assert';
import { EditorInput } from 'vs/workbench/common/editor';
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
class MyEditorInput extends EditorInput {
readonly resource = undefined;
@@ -36,6 +37,8 @@ suite('Workbench editor input', () => {
});
test('DiffEditorInput', () => {
const instantiationService = workbenchInstantiationService();
let counter = 0;
let input = new MyEditorInput();
input.onDispose(() => {
@@ -49,7 +52,7 @@ suite('Workbench editor input', () => {
counter++;
});
let diffInput = new DiffEditorInput('name', 'description', input, otherInput);
let diffInput = instantiationService.createInstance(DiffEditorInput, 'name', 'description', input, otherInput, undefined);
assert.equal(diffInput.originalInput, input);
assert.equal(diffInput.modifiedInput, otherInput);
@@ -62,11 +65,13 @@ suite('Workbench editor input', () => {
});
test('DiffEditorInput disposes when input inside disposes', function () {
const instantiationService = workbenchInstantiationService();
let counter = 0;
let input = new MyEditorInput();
let otherInput = new MyEditorInput();
let diffInput = new DiffEditorInput('name', 'description', input, otherInput);
let diffInput = instantiationService.createInstance(DiffEditorInput, 'name', 'description', input, otherInput, undefined);
diffInput.onDispose(() => {
counter++;
assert(true);
@@ -77,7 +82,7 @@ suite('Workbench editor input', () => {
input = new MyEditorInput();
otherInput = new MyEditorInput();
let diffInput2 = new DiffEditorInput('name', 'description', input, otherInput);
let diffInput2 = instantiationService.createInstance(DiffEditorInput, 'name', 'description', input, otherInput, undefined);
diffInput2.onDispose(() => {
counter++;
assert(true);

View File

@@ -325,6 +325,62 @@ suite('Workbench EditorPane', () => {
assert.ok(!res);
});
test('EditoMemento - clear on editor dispose', function () {
const testGroup0 = new TestEditorGroupView(0);
interface TestViewState {
line: number;
}
class TestEditorInput extends EditorInput {
constructor(public resource: URI, private id = 'testEditorInputForMementoTest') {
super();
}
getTypeId() { return 'testEditorInputForMementoTest'; }
resolve(): Promise<IEditorModel> { return Promise.resolve(null!); }
matches(other: TestEditorInput): boolean {
return other && this.id === other.id && other instanceof TestEditorInput;
}
}
const rawMemento = Object.create(null);
let memento = new EditorMemento<TestViewState>('id', 'key', rawMemento, 3, new TestEditorGroupsService());
const testInputA = new TestEditorInput(URI.file('/A'));
let res = memento.loadEditorState(testGroup0, testInputA);
assert.ok(!res);
memento.saveEditorState(testGroup0, testInputA.resource, { line: 3 });
res = memento.loadEditorState(testGroup0, testInputA);
assert.ok(res);
assert.equal(res!.line, 3);
// State not yet removed when input gets disposed
// because we used resource
testInputA.dispose();
res = memento.loadEditorState(testGroup0, testInputA);
assert.ok(res);
const testInputB = new TestEditorInput(URI.file('/B'));
res = memento.loadEditorState(testGroup0, testInputB);
assert.ok(!res);
memento.saveEditorState(testGroup0, testInputB.resource, { line: 3 });
res = memento.loadEditorState(testGroup0, testInputB);
assert.ok(res);
assert.equal(res!.line, 3);
memento.clearEditorStateOnDispose(testInputB.resource, testInputB);
// State removed when input gets disposed
testInputB.dispose();
res = memento.loadEditorState(testGroup0, testInputB);
assert.ok(!res);
});
return {
MyEditor: MyEditor,
MyOtherEditor: MyOtherEditor

View File

@@ -63,7 +63,7 @@ import { timeout } from 'vs/base/common/async';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { ViewletDescriptor, Viewlet } from 'vs/workbench/browser/viewlet';
import { IViewlet } from 'vs/workbench/common/viewlet';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { isLinux, isWindows } from 'vs/base/common/platform';
import { LabelService } from 'vs/workbench/services/label/common/labelService';
import { Part } from 'vs/workbench/browser/part';
@@ -104,7 +104,6 @@ import { IListService } from 'vs/platform/list/browser/listService';
import { win32, posix } from 'vs/base/common/path';
import { TestWorkingCopyService, TestContextService, TestStorageService, TestTextResourcePropertiesService, TestExtensionService } from 'vs/workbench/test/common/workbenchTestServices';
import { IViewsService, IView, ViewContainer, ViewContainerLocation } from 'vs/workbench/common/views';
import { IStorageKeysSyncRegistryService, StorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
import { IPaneComposite } from 'vs/workbench/common/panecomposite';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
import { UriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentityService';
@@ -117,7 +116,7 @@ import { ColorScheme } from 'vs/platform/theme/common/theme';
import { Iterable } from 'vs/base/common/iterator';
export function createFileEditorInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
return instantiationService.createInstance(FileEditorInput, resource, undefined, undefined, undefined);
return instantiationService.createInstance(FileEditorInput, resource, undefined, undefined, undefined, undefined, undefined);
}
export interface ITestInstantiationService extends IInstantiationService {
@@ -151,7 +150,7 @@ export function workbenchInstantiationService(overrides?: {
instantiationService.stub(IDialogService, new TestDialogService());
const accessibilityService = new TestAccessibilityService();
instantiationService.stub(IAccessibilityService, accessibilityService);
instantiationService.stub(IFileDialogService, new TestFileDialogService());
instantiationService.stub(IFileDialogService, instantiationService.createInstance(TestFileDialogService));
instantiationService.stub(IModeService, instantiationService.createInstance(ModeServiceImpl));
instantiationService.stub(IHistoryService, new TestHistoryService());
instantiationService.stub(ITextResourcePropertiesService, new TestTextResourcePropertiesService(configService));
@@ -185,7 +184,6 @@ export function workbenchInstantiationService(overrides?: {
instantiationService.stub(IViewletService, new TestViewletService());
instantiationService.stub(IListService, new TestListService());
instantiationService.stub(IQuickInputService, new QuickInputService(configService, instantiationService, keybindingService, contextKeyService, themeService, accessibilityService, layoutService));
instantiationService.stub(IStorageKeysSyncRegistryService, new StorageKeysSyncRegistryService());
return instantiationService;
}
@@ -391,9 +389,12 @@ export class TestFileDialogService implements IFileDialogService {
private confirmResult!: ConfirmResult;
defaultFilePath(_schemeFilter?: string): URI | undefined { return undefined; }
defaultFolderPath(_schemeFilter?: string): URI | undefined { return undefined; }
defaultWorkspacePath(_schemeFilter?: string): URI | undefined { return undefined; }
constructor(
@IPathService private readonly pathService: IPathService
) { }
async defaultFilePath(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }
async defaultFolderPath(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }
async defaultWorkspacePath(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }
pickFileFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }
pickFileAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }
pickFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }
@@ -1176,6 +1177,8 @@ export class TestFileEditorInput extends EditorInput implements IFileEditorInput
setPreferredResource(resource: URI): void { }
setEncoding(encoding: string) { }
getEncoding() { return undefined; }
setPreferredName(name: string): void { }
setPreferredDescription(description: string): void { }
setPreferredEncoding(encoding: string) { }
setMode(mode: string) { }
setPreferredMode(mode: string) { }
@@ -1221,12 +1224,12 @@ export class TestEditorPart extends EditorPart {
}
clearState(): void {
const workspaceMemento = this.getMemento(StorageScope.WORKSPACE);
const workspaceMemento = this.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
for (const key of Object.keys(workspaceMemento)) {
delete workspaceMemento[key];
}
const globalMemento = this.getMemento(StorageScope.GLOBAL);
const globalMemento = this.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
for (const key of Object.keys(globalMemento)) {
delete globalMemento[key];
}

View File

@@ -4,8 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { StorageScope, IStorageService } from 'vs/platform/storage/common/storage';
import { StorageScope, IStorageService, StorageTarget } from 'vs/platform/storage/common/storage';
import { Memento } from 'vs/workbench/common/memento';
import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
@@ -21,26 +20,26 @@ suite('Memento', () => {
let myMemento = new Memento('memento.test', storage);
// Global
let memento = myMemento.getMemento(StorageScope.GLOBAL);
let memento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
memento.foo = [1, 2, 3];
let globalMemento = myMemento.getMemento(StorageScope.GLOBAL);
let globalMemento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert.deepEqual(globalMemento, memento);
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE);
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert(memento);
memento.foo = 'Hello World';
myMemento.saveMemento();
// Global
memento = myMemento.getMemento(StorageScope.GLOBAL);
memento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: [1, 2, 3] });
globalMemento = myMemento.getMemento(StorageScope.GLOBAL);
globalMemento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert.deepEqual(globalMemento, memento);
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE);
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: 'Hello World' });
// Assert the Mementos are stored properly in storage
@@ -49,21 +48,21 @@ suite('Memento', () => {
assert.deepEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.WORKSPACE)!), { foo: 'Hello World' });
// Delete Global
memento = myMemento.getMemento(context!);
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
delete memento.foo;
// Delete Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE);
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
delete memento.foo;
myMemento.saveMemento();
// Global
memento = myMemento.getMemento(context!);
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
assert.deepEqual(memento, {});
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE);
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert.deepEqual(memento, {});
// Assert the Mementos are also removed from storage
@@ -76,63 +75,63 @@ suite('Memento', () => {
let myMemento = new Memento('memento.test', storage);
// Global
let memento = myMemento.getMemento(context!);
let memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
memento.foo = [1, 2, 3];
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE);
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert(memento);
memento.foo = 'Hello World';
myMemento.saveMemento();
// Global
memento = myMemento.getMemento(context!);
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: [1, 2, 3] });
let globalMemento = myMemento.getMemento(StorageScope.GLOBAL);
let globalMemento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert.deepEqual(globalMemento, memento);
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE);
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: 'Hello World' });
// Global
memento = myMemento.getMemento(context!);
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
memento.foo = [4, 5, 6];
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE);
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert(memento);
memento.foo = 'World Hello';
myMemento.saveMemento();
// Global
memento = myMemento.getMemento(context!);
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: [4, 5, 6] });
globalMemento = myMemento.getMemento(StorageScope.GLOBAL);
globalMemento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert.deepEqual(globalMemento, memento);
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE);
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: 'World Hello' });
// Delete Global
memento = myMemento.getMemento(context!);
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
delete memento.foo;
// Delete Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE);
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
delete memento.foo;
myMemento.saveMemento();
// Global
memento = myMemento.getMemento(context!);
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
assert.deepEqual(memento, {});
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE);
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert.deepEqual(memento, {});
});
@@ -141,18 +140,18 @@ suite('Memento', () => {
let myMemento2 = new Memento('memento.test', storage);
// Global
let memento = myMemento.getMemento(context!);
let memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
memento.foo = [1, 2, 3];
memento = myMemento2.getMemento(context!);
memento = myMemento2.getMemento(context!, StorageTarget.MACHINE);
memento.bar = [1, 2, 3];
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE);
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert(memento);
memento.foo = 'Hello World';
memento = myMemento2.getMemento(StorageScope.WORKSPACE);
memento = myMemento2.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert(memento);
memento.bar = 'Hello World';
@@ -160,21 +159,21 @@ suite('Memento', () => {
myMemento2.saveMemento();
// Global
memento = myMemento.getMemento(context!);
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: [1, 2, 3], bar: [1, 2, 3] });
let globalMemento = myMemento.getMemento(StorageScope.GLOBAL);
let globalMemento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert.deepEqual(globalMemento, memento);
memento = myMemento2.getMemento(context!);
memento = myMemento2.getMemento(context!, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: [1, 2, 3], bar: [1, 2, 3] });
globalMemento = myMemento2.getMemento(StorageScope.GLOBAL);
globalMemento = myMemento2.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert.deepEqual(globalMemento, memento);
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE);
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: 'Hello World', bar: 'Hello World' });
memento = myMemento2.getMemento(StorageScope.WORKSPACE);
memento = myMemento2.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: 'Hello World', bar: 'Hello World' });
});
});

View File

@@ -13,7 +13,7 @@ import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
import { isLinux, isMacintosh } from 'vs/base/common/platform';
import { InMemoryStorageService, IWillSaveStateEvent } from 'vs/platform/storage/common/storage';
import { InMemoryStorageService, WillSaveStateReason } from 'vs/platform/storage/common/storage';
import { WorkingCopyService, IWorkingCopy, IWorkingCopyBackup, WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopyService';
import { NullExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IWorkingCopyFileService, IWorkingCopyFileOperationParticipant, WorkingCopyFileEvent } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
@@ -121,8 +121,10 @@ export class TestContextService implements IWorkspaceContextService {
}
export class TestStorageService extends InMemoryStorageService {
readonly _onWillSaveState = this._register(new Emitter<IWillSaveStateEvent>());
readonly onWillSaveState = this._onWillSaveState.event;
emitWillSaveState(reason: WillSaveStateReason): void {
super.emitWillSaveState(reason);
}
}
export class TestWorkingCopyService extends WorkingCopyService { }

View File

@@ -40,7 +40,7 @@ import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/ur
import { MouseInputEvent } from 'vs/base/parts/sandbox/common/electronTypes';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IOSProperties, IOSStatistics } from 'vs/platform/native/common/native';
import { homedir } from 'os';
import { homedir, release } from 'os';
export const TestWorkbenchConfiguration: INativeWorkbenchConfiguration = {
windowId: 0,
@@ -54,6 +54,7 @@ export const TestWorkbenchConfiguration: INativeWorkbenchConfiguration = {
execPath: process.execPath,
perfEntries: [],
colorScheme: { dark: true, highContrast: false },
os: { release: release() },
...parseArgs(process.argv, OPTIONS)
};