|
|
|
|
@@ -13,6 +13,7 @@ import { TestRPCProtocol } from './testRPCProtocol';
|
|
|
|
|
import { normalize } from 'vs/base/common/paths';
|
|
|
|
|
import { IWorkspaceFolderData } from 'vs/platform/workspace/common/workspace';
|
|
|
|
|
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
|
|
|
|
import { NullLogService } from 'vs/platform/log/common/log';
|
|
|
|
|
|
|
|
|
|
suite('ExtHostWorkspace', function () {
|
|
|
|
|
|
|
|
|
|
@@ -38,7 +39,7 @@ suite('ExtHostWorkspace', function () {
|
|
|
|
|
|
|
|
|
|
test('asRelativePath', function () {
|
|
|
|
|
|
|
|
|
|
const ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/Applications/NewsWoWBot'), 0)], name: 'Test' });
|
|
|
|
|
const ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/Applications/NewsWoWBot'), 0)], name: 'Test' }, new NullLogService());
|
|
|
|
|
|
|
|
|
|
assertAsRelativePath(ws, '/Coding/Applications/NewsWoWBot/bernd/das/brot', 'bernd/das/brot');
|
|
|
|
|
assertAsRelativePath(ws, '/Apps/DartPubCache/hosted/pub.dartlang.org/convert-2.0.1/lib/src/hex.dart',
|
|
|
|
|
@@ -52,7 +53,7 @@ suite('ExtHostWorkspace', function () {
|
|
|
|
|
test('asRelativePath, same paths, #11402', function () {
|
|
|
|
|
const root = '/home/aeschli/workspaces/samples/docker';
|
|
|
|
|
const input = '/home/aeschli/workspaces/samples/docker';
|
|
|
|
|
const ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' });
|
|
|
|
|
const ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService());
|
|
|
|
|
|
|
|
|
|
assertAsRelativePath(ws, (input), input);
|
|
|
|
|
|
|
|
|
|
@@ -61,20 +62,20 @@ suite('ExtHostWorkspace', function () {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('asRelativePath, no workspace', function () {
|
|
|
|
|
const ws = new ExtHostWorkspace(new TestRPCProtocol(), null);
|
|
|
|
|
const ws = new ExtHostWorkspace(new TestRPCProtocol(), null, new NullLogService());
|
|
|
|
|
assertAsRelativePath(ws, (''), '');
|
|
|
|
|
assertAsRelativePath(ws, ('/foo/bar'), '/foo/bar');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('asRelativePath, multiple folders', function () {
|
|
|
|
|
const ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' });
|
|
|
|
|
const ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' }, new NullLogService());
|
|
|
|
|
assertAsRelativePath(ws, '/Coding/One/file.txt', 'One/file.txt');
|
|
|
|
|
assertAsRelativePath(ws, '/Coding/Two/files/out.txt', 'Two/files/out.txt');
|
|
|
|
|
assertAsRelativePath(ws, '/Coding/Two2/files/out.txt', '/Coding/Two2/files/out.txt');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('slightly inconsistent behaviour of asRelativePath and getWorkspaceFolder, #31553', function () {
|
|
|
|
|
const mrws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' });
|
|
|
|
|
const mrws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' }, new NullLogService());
|
|
|
|
|
|
|
|
|
|
assertAsRelativePath(mrws, '/Coding/One/file.txt', 'One/file.txt');
|
|
|
|
|
assertAsRelativePath(mrws, '/Coding/One/file.txt', 'One/file.txt', true);
|
|
|
|
|
@@ -86,7 +87,7 @@ suite('ExtHostWorkspace', function () {
|
|
|
|
|
assertAsRelativePath(mrws, '/Coding/Two2/files/out.txt', '/Coding/Two2/files/out.txt', true);
|
|
|
|
|
assertAsRelativePath(mrws, '/Coding/Two2/files/out.txt', '/Coding/Two2/files/out.txt', false);
|
|
|
|
|
|
|
|
|
|
const srws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0)], name: 'Test' });
|
|
|
|
|
const srws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0)], name: 'Test' }, new NullLogService());
|
|
|
|
|
assertAsRelativePath(srws, '/Coding/One/file.txt', 'file.txt');
|
|
|
|
|
assertAsRelativePath(srws, '/Coding/One/file.txt', 'file.txt', false);
|
|
|
|
|
assertAsRelativePath(srws, '/Coding/One/file.txt', 'One/file.txt', true);
|
|
|
|
|
@@ -96,24 +97,24 @@ suite('ExtHostWorkspace', function () {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('getPath, legacy', function () {
|
|
|
|
|
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] });
|
|
|
|
|
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService());
|
|
|
|
|
assert.equal(ws.getPath(), undefined);
|
|
|
|
|
|
|
|
|
|
ws = new ExtHostWorkspace(new TestRPCProtocol(), null);
|
|
|
|
|
ws = new ExtHostWorkspace(new TestRPCProtocol(), null, new NullLogService());
|
|
|
|
|
assert.equal(ws.getPath(), undefined);
|
|
|
|
|
|
|
|
|
|
ws = new ExtHostWorkspace(new TestRPCProtocol(), undefined);
|
|
|
|
|
ws = new ExtHostWorkspace(new TestRPCProtocol(), undefined, new NullLogService());
|
|
|
|
|
assert.equal(ws.getPath(), undefined);
|
|
|
|
|
|
|
|
|
|
ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.file('Folder'), 0), aWorkspaceFolderData(URI.file('Another/Folder'), 1)] });
|
|
|
|
|
ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.file('Folder'), 0), aWorkspaceFolderData(URI.file('Another/Folder'), 1)] }, new NullLogService());
|
|
|
|
|
assert.equal(ws.getPath().replace(/\\/g, '/'), '/Folder');
|
|
|
|
|
|
|
|
|
|
ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.file('/Folder'), 0)] });
|
|
|
|
|
ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.file('/Folder'), 0)] }, new NullLogService());
|
|
|
|
|
assert.equal(ws.getPath().replace(/\\/g, '/'), '/Folder');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('WorkspaceFolder has name and index', function () {
|
|
|
|
|
const ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' });
|
|
|
|
|
const ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' }, new NullLogService());
|
|
|
|
|
|
|
|
|
|
const [one, two] = ws.getWorkspaceFolders();
|
|
|
|
|
|
|
|
|
|
@@ -132,7 +133,7 @@ suite('ExtHostWorkspace', function () {
|
|
|
|
|
aWorkspaceFolderData(URI.file('/Coding/Two'), 1),
|
|
|
|
|
aWorkspaceFolderData(URI.file('/Coding/Two/Nested'), 2)
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
}, new NullLogService());
|
|
|
|
|
|
|
|
|
|
let folder = ws.getWorkspaceFolder(URI.file('/foo/bar'));
|
|
|
|
|
assert.equal(folder, undefined);
|
|
|
|
|
@@ -172,7 +173,7 @@ suite('ExtHostWorkspace', function () {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('Multiroot change event should have a delta, #29641', function (done) {
|
|
|
|
|
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] });
|
|
|
|
|
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService());
|
|
|
|
|
|
|
|
|
|
let finished = false;
|
|
|
|
|
const finish = (error?) => {
|
|
|
|
|
@@ -235,7 +236,7 @@ suite('ExtHostWorkspace', function () {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('Multiroot change keeps existing workspaces live', function () {
|
|
|
|
|
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0)] });
|
|
|
|
|
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0)] }, new NullLogService());
|
|
|
|
|
|
|
|
|
|
let firstFolder = ws.getWorkspaceFolders()[0];
|
|
|
|
|
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar2'), 0), aWorkspaceFolderData(URI.parse('foo:bar'), 1, 'renamed')] });
|
|
|
|
|
@@ -255,7 +256,7 @@ suite('ExtHostWorkspace', function () {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('updateWorkspaceFolders - invalid arguments', function () {
|
|
|
|
|
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] });
|
|
|
|
|
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService());
|
|
|
|
|
|
|
|
|
|
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, null, null));
|
|
|
|
|
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 0));
|
|
|
|
|
@@ -264,7 +265,7 @@ suite('ExtHostWorkspace', function () {
|
|
|
|
|
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, -1, 0));
|
|
|
|
|
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, -1, -1));
|
|
|
|
|
|
|
|
|
|
ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0)] });
|
|
|
|
|
ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0)] }, new NullLogService());
|
|
|
|
|
|
|
|
|
|
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 1, 1));
|
|
|
|
|
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 2));
|
|
|
|
|
@@ -286,7 +287,7 @@ suite('ExtHostWorkspace', function () {
|
|
|
|
|
assertRegistered: undefined
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ws = new ExtHostWorkspace(protocol, { id: 'foo', name: 'Test', folders: [] });
|
|
|
|
|
const ws = new ExtHostWorkspace(protocol, { id: 'foo', name: 'Test', folders: [] }, new NullLogService());
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Add one folder
|
|
|
|
|
@@ -519,7 +520,7 @@ suite('ExtHostWorkspace', function () {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] });
|
|
|
|
|
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService());
|
|
|
|
|
let sub = ws.onDidChangeWorkspace(e => {
|
|
|
|
|
try {
|
|
|
|
|
assert.throws(() => {
|
|
|
|
|
@@ -542,7 +543,7 @@ suite('ExtHostWorkspace', function () {
|
|
|
|
|
id: 'foo', name: 'Test', folders: [
|
|
|
|
|
aWorkspaceFolderData(URI.file('c:/Users/marek/Desktop/vsc_test/'), 0)
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
}, new NullLogService());
|
|
|
|
|
|
|
|
|
|
assert.ok(ws.getWorkspaceFolder(URI.file('c:/Users/marek/Desktop/vsc_test/a.txt')));
|
|
|
|
|
assert.ok(ws.getWorkspaceFolder(URI.file('C:/Users/marek/Desktop/vsc_test/b.txt')));
|
|
|
|
|
|