mirror of
https://github.com/coder/code-server.git
synced 2026-05-16 09:17:25 +02:00
chore(vscode): update to 1.53.2
These conflicts will be resolved in the following commits. We do it this way so that PR review is possible.
This commit is contained in:
@@ -4,16 +4,17 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as resources from 'vs/base/common/resources';
|
||||
import { joinPath, basenameOrAuthority } from 'vs/base/common/resources';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { TernarySearchTree } from 'vs/base/common/map';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IWorkspaceIdentifier, IStoredWorkspaceFolder, isRawFileWorkspaceFolder, isRawUriWorkspaceFolder, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IWorkspaceIdentifier, IStoredWorkspaceFolder, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IWorkspaceFolderProvider } from 'vs/base/common/labels';
|
||||
|
||||
export const IWorkspaceContextService = createDecorator<IWorkspaceContextService>('contextService');
|
||||
|
||||
export interface IWorkspaceContextService extends IWorkspaceFolderProvider {
|
||||
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
/**
|
||||
@@ -58,9 +59,9 @@ export interface IWorkspaceContextService extends IWorkspaceFolderProvider {
|
||||
getWorkspaceFolder(resource: URI): IWorkspaceFolder | null;
|
||||
|
||||
/**
|
||||
* Return `true` if the current workspace has the given identifier otherwise `false`.
|
||||
* Return `true` if the current workspace has the given identifier or root URI otherwise `false`.
|
||||
*/
|
||||
isCurrentWorkspace(workspaceIdentifier: ISingleFolderWorkspaceIdentifier | IWorkspaceIdentifier): boolean;
|
||||
isCurrentWorkspace(workspaceIdOrFolder: IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI): boolean;
|
||||
|
||||
/**
|
||||
* Returns if the provided resource is inside the workspace or not.
|
||||
@@ -80,14 +81,6 @@ export interface IWorkspaceFoldersChangeEvent {
|
||||
changed: IWorkspaceFolder[];
|
||||
}
|
||||
|
||||
export namespace IWorkspace {
|
||||
export function isIWorkspace(thing: unknown): thing is IWorkspace {
|
||||
return !!(thing && typeof thing === 'object'
|
||||
&& typeof (thing as IWorkspace).id === 'string'
|
||||
&& Array.isArray((thing as IWorkspace).folders));
|
||||
}
|
||||
}
|
||||
|
||||
export interface IWorkspace {
|
||||
|
||||
/**
|
||||
@@ -106,6 +99,14 @@ export interface IWorkspace {
|
||||
readonly configuration?: URI | null;
|
||||
}
|
||||
|
||||
export function isWorkspace(thing: unknown): thing is IWorkspace {
|
||||
const candidate = thing as IWorkspace | undefined;
|
||||
|
||||
return !!(candidate && typeof candidate === 'object'
|
||||
&& typeof candidate.id === 'string'
|
||||
&& Array.isArray(candidate.folders));
|
||||
}
|
||||
|
||||
export interface IWorkspaceFolderData {
|
||||
|
||||
/**
|
||||
@@ -125,15 +126,6 @@ export interface IWorkspaceFolderData {
|
||||
readonly index: number;
|
||||
}
|
||||
|
||||
export namespace IWorkspaceFolder {
|
||||
export function isIWorkspaceFolder(thing: unknown): thing is IWorkspaceFolder {
|
||||
return !!(thing && typeof thing === 'object'
|
||||
&& URI.isUri((thing as IWorkspaceFolder).uri)
|
||||
&& typeof (thing as IWorkspaceFolder).name === 'string'
|
||||
&& typeof (thing as IWorkspaceFolder).toResource === 'function');
|
||||
}
|
||||
}
|
||||
|
||||
export interface IWorkspaceFolder extends IWorkspaceFolderData {
|
||||
|
||||
/**
|
||||
@@ -142,6 +134,15 @@ export interface IWorkspaceFolder extends IWorkspaceFolderData {
|
||||
toResource: (relativePath: string) => URI;
|
||||
}
|
||||
|
||||
export function isWorkspaceFolder(thing: unknown): thing is IWorkspaceFolder {
|
||||
const candidate = thing as IWorkspaceFolder;
|
||||
|
||||
return !!(candidate && typeof candidate === 'object'
|
||||
&& URI.isUri(candidate.uri)
|
||||
&& typeof candidate.name === 'string'
|
||||
&& typeof candidate.toResource === 'function');
|
||||
}
|
||||
|
||||
export class Workspace implements IWorkspace {
|
||||
|
||||
private _foldersMap: TernarySearchTree<URI, WorkspaceFolder> = TernarySearchTree.forUris<WorkspaceFolder>(this._ignorePathCasing);
|
||||
@@ -222,7 +223,7 @@ export class WorkspaceFolder implements IWorkspaceFolder {
|
||||
}
|
||||
|
||||
toResource(relativePath: string): URI {
|
||||
return resources.joinPath(this.uri, relativePath);
|
||||
return joinPath(this.uri, relativePath);
|
||||
}
|
||||
|
||||
toJSON(): IWorkspaceFolderData {
|
||||
@@ -231,43 +232,5 @@ export class WorkspaceFolder implements IWorkspaceFolder {
|
||||
}
|
||||
|
||||
export function toWorkspaceFolder(resource: URI): WorkspaceFolder {
|
||||
return new WorkspaceFolder({ uri: resource, index: 0, name: resources.basenameOrAuthority(resource) }, { uri: resource.toString() });
|
||||
}
|
||||
|
||||
export function toWorkspaceFolders(configuredFolders: IStoredWorkspaceFolder[], workspaceConfigFile: URI): WorkspaceFolder[] {
|
||||
let result: WorkspaceFolder[] = [];
|
||||
let seen: Set<string> = new Set();
|
||||
|
||||
const relativeTo = resources.dirname(workspaceConfigFile);
|
||||
for (let configuredFolder of configuredFolders) {
|
||||
let uri: URI | null = null;
|
||||
if (isRawFileWorkspaceFolder(configuredFolder)) {
|
||||
if (configuredFolder.path) {
|
||||
uri = resources.resolvePath(relativeTo, configuredFolder.path);
|
||||
}
|
||||
} else if (isRawUriWorkspaceFolder(configuredFolder)) {
|
||||
try {
|
||||
uri = URI.parse(configuredFolder.uri);
|
||||
// this makes sure all workspace folder are absolute
|
||||
if (uri.path[0] !== '/') {
|
||||
uri = uri.with({ path: '/' + uri.path });
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
if (uri) {
|
||||
// remove duplicates
|
||||
let comparisonKey = resources.getComparisonKey(uri);
|
||||
if (!seen.has(comparisonKey)) {
|
||||
seen.add(comparisonKey);
|
||||
|
||||
const name = configuredFolder.name || resources.basenameOrAuthority(uri);
|
||||
result.push(new WorkspaceFolder({ uri, name, index: result.length }, configuredFolder));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return new WorkspaceFolder({ uri: resource, index: 0, name: basenameOrAuthority(resource) }, { uri: resource.toString() });
|
||||
}
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import { Workspace, toWorkspaceFolders, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import { Workspace, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IRawFileWorkspaceFolder } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IRawFileWorkspaceFolder, toWorkspaceFolders } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { isLinux, isWindows } from 'vs/base/common/platform';
|
||||
import { extUriBiasedIgnorePathCase } from 'vs/base/common/resources';
|
||||
|
||||
suite('Workspace', () => {
|
||||
|
||||
@@ -70,7 +71,7 @@ suite('Workspace', () => {
|
||||
});
|
||||
|
||||
test('toWorkspaceFolders with single absolute folder', () => {
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test' }], workspaceConfigUri);
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test' }], workspaceConfigUri, extUriBiasedIgnorePathCase);
|
||||
|
||||
assert.equal(actual.length, 1);
|
||||
assert.equal(actual[0].uri.fsPath, testFolderUri.fsPath);
|
||||
@@ -80,7 +81,7 @@ suite('Workspace', () => {
|
||||
});
|
||||
|
||||
test('toWorkspaceFolders with single relative folder', () => {
|
||||
const actual = toWorkspaceFolders([{ path: './test' }], workspaceConfigUri);
|
||||
const actual = toWorkspaceFolders([{ path: './test' }], workspaceConfigUri, extUriBiasedIgnorePathCase);
|
||||
|
||||
assert.equal(actual.length, 1);
|
||||
assert.equal(actual[0].uri.fsPath, testFolderUri.fsPath);
|
||||
@@ -90,7 +91,7 @@ suite('Workspace', () => {
|
||||
});
|
||||
|
||||
test('toWorkspaceFolders with single absolute folder with name', () => {
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test', name: 'hello' }], workspaceConfigUri);
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test', name: 'hello' }], workspaceConfigUri, extUriBiasedIgnorePathCase);
|
||||
|
||||
assert.equal(actual.length, 1);
|
||||
|
||||
@@ -101,7 +102,7 @@ suite('Workspace', () => {
|
||||
});
|
||||
|
||||
test('toWorkspaceFolders with multiple unique absolute folders', () => {
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test2' }, { path: '/src/test3' }, { path: '/src/test1' }], workspaceConfigUri);
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test2' }, { path: '/src/test3' }, { path: '/src/test1' }], workspaceConfigUri, extUriBiasedIgnorePathCase);
|
||||
|
||||
assert.equal(actual.length, 3);
|
||||
assert.equal(actual[0].uri.fsPath, test2FolderUri.fsPath);
|
||||
@@ -121,7 +122,7 @@ suite('Workspace', () => {
|
||||
});
|
||||
|
||||
test('toWorkspaceFolders with multiple unique absolute folders with names', () => {
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test2' }, { path: '/src/test3', name: 'noName' }, { path: '/src/test1' }], workspaceConfigUri);
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test2' }, { path: '/src/test3', name: 'noName' }, { path: '/src/test1' }], workspaceConfigUri, extUriBiasedIgnorePathCase);
|
||||
|
||||
assert.equal(actual.length, 3);
|
||||
assert.equal(actual[0].uri.fsPath, test2FolderUri.fsPath);
|
||||
@@ -141,7 +142,7 @@ suite('Workspace', () => {
|
||||
});
|
||||
|
||||
test('toWorkspaceFolders with multiple unique absolute and relative folders', () => {
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test2' }, { path: '/abc/test3', name: 'noName' }, { path: './test1' }], workspaceConfigUri);
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test2' }, { path: '/abc/test3', name: 'noName' }, { path: './test1' }], workspaceConfigUri, extUriBiasedIgnorePathCase);
|
||||
|
||||
assert.equal(actual.length, 3);
|
||||
assert.equal(actual[0].uri.fsPath, test2FolderUri.fsPath);
|
||||
@@ -161,7 +162,7 @@ suite('Workspace', () => {
|
||||
});
|
||||
|
||||
test('toWorkspaceFolders with multiple absolute folders with duplicates', () => {
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test2' }, { path: '/src/test2', name: 'noName' }, { path: '/src/test1' }], workspaceConfigUri);
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test2' }, { path: '/src/test2', name: 'noName' }, { path: '/src/test1' }], workspaceConfigUri, extUriBiasedIgnorePathCase);
|
||||
|
||||
assert.equal(actual.length, 2);
|
||||
assert.equal(actual[0].uri.fsPath, test2FolderUri.fsPath);
|
||||
@@ -176,7 +177,7 @@ suite('Workspace', () => {
|
||||
});
|
||||
|
||||
test('toWorkspaceFolders with multiple absolute and relative folders with duplicates', () => {
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test2' }, { path: '/src/test3', name: 'noName' }, { path: './test3' }, { path: '/abc/test1' }], workspaceConfigUri);
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test2' }, { path: '/src/test3', name: 'noName' }, { path: './test3' }, { path: '/abc/test1' }], workspaceConfigUri, extUriBiasedIgnorePathCase);
|
||||
|
||||
assert.equal(actual.length, 3);
|
||||
assert.equal(actual[0].uri.fsPath, test2FolderUri.fsPath);
|
||||
@@ -196,7 +197,7 @@ suite('Workspace', () => {
|
||||
});
|
||||
|
||||
test('toWorkspaceFolders with multiple absolute and relative folders with invalid paths', () => {
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test2' }, { path: '', name: 'noName' }, { path: './test3' }, { path: '/abc/test1' }], workspaceConfigUri);
|
||||
const actual = toWorkspaceFolders([{ path: '/src/test2' }, { path: '', name: 'noName' }, { path: './test3' }, { path: '/abc/test1' }], workspaceConfigUri, extUriBiasedIgnorePathCase);
|
||||
|
||||
assert.equal(actual.length, 3);
|
||||
assert.equal(actual[0].uri.fsPath, test2FolderUri.fsPath);
|
||||
|
||||
Reference in New Issue
Block a user