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,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { workspace, extensions, Uri, EventEmitter, Disposable } from 'vscode';
|
||||
import { resolvePath, joinPath } from './requests';
|
||||
import { Utils } from 'vscode-uri';
|
||||
|
||||
export function getCustomDataSource(toDispose: Disposable[]) {
|
||||
let pathsInWorkspace = getCustomDataPathsInAllWorkspaces();
|
||||
@ -50,7 +50,7 @@ function getCustomDataPathsInAllWorkspaces(): string[] {
|
||||
if (Array.isArray(paths)) {
|
||||
for (const path of paths) {
|
||||
if (typeof path === 'string') {
|
||||
dataPaths.push(resolvePath(rootFolder, path).toString());
|
||||
dataPaths.push(Utils.resolvePath(rootFolder, path).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -80,7 +80,7 @@ function getCustomDataPathsFromAllExtensions(): string[] {
|
||||
const customData = extension.packageJSON?.contributes?.css?.customData;
|
||||
if (Array.isArray(customData)) {
|
||||
for (const rp of customData) {
|
||||
dataPaths.push(joinPath(extension.extensionUri, rp).toString());
|
||||
dataPaths.push(Utils.joinPath(extension.extensionUri, rp).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,11 @@
|
||||
|
||||
import * as fs from 'fs';
|
||||
import { Uri } from 'vscode';
|
||||
import { getScheme, RequestService, FileType } from '../requests';
|
||||
import { RequestService, FileType } from '../requests';
|
||||
|
||||
export function getNodeFSRequestService(): RequestService {
|
||||
function ensureFileUri(location: string) {
|
||||
if (getScheme(location) !== 'file') {
|
||||
if (!location.startsWith('file://')) {
|
||||
throw new Error('fileRequestService can only handle file URLs');
|
||||
}
|
||||
}
|
||||
|
@ -8,14 +8,14 @@ import { RequestType, CommonLanguageClient } from 'vscode-languageclient';
|
||||
import { Runtime } from './cssClient';
|
||||
|
||||
export namespace FsContentRequest {
|
||||
export const type: RequestType<{ uri: string; encoding?: string; }, string, any, any> = new RequestType('fs/content');
|
||||
export const type: RequestType<{ uri: string; encoding?: string; }, string, any> = new RequestType('fs/content');
|
||||
}
|
||||
export namespace FsStatRequest {
|
||||
export const type: RequestType<string, FileStat, any, any> = new RequestType('fs/stat');
|
||||
export const type: RequestType<string, FileStat, any> = new RequestType('fs/stat');
|
||||
}
|
||||
|
||||
export namespace FsReadDirRequest {
|
||||
export const type: RequestType<string, [string, FileType][], any, any> = new RequestType('fs/readDir');
|
||||
export const type: RequestType<string, [string, FileType][], any> = new RequestType('fs/readDir');
|
||||
}
|
||||
|
||||
export function serveFileSystemRequests(client: CommonLanguageClient, runtime: Runtime) {
|
||||
@ -88,61 +88,3 @@ export interface RequestService {
|
||||
stat(uri: string): Promise<FileStat>;
|
||||
readDirectory(uri: string): Promise<[string, FileType][]>;
|
||||
}
|
||||
|
||||
export function getScheme(uri: string) {
|
||||
return uri.substr(0, uri.indexOf(':'));
|
||||
}
|
||||
|
||||
export function dirname(uri: string) {
|
||||
const lastIndexOfSlash = uri.lastIndexOf('/');
|
||||
return lastIndexOfSlash !== -1 ? uri.substr(0, lastIndexOfSlash) : '';
|
||||
}
|
||||
|
||||
export function basename(uri: string) {
|
||||
const lastIndexOfSlash = uri.lastIndexOf('/');
|
||||
return uri.substr(lastIndexOfSlash + 1);
|
||||
}
|
||||
|
||||
const Slash = '/'.charCodeAt(0);
|
||||
const Dot = '.'.charCodeAt(0);
|
||||
|
||||
export function isAbsolutePath(path: string) {
|
||||
return path.charCodeAt(0) === Slash;
|
||||
}
|
||||
|
||||
export function resolvePath(uri: Uri, path: string): Uri {
|
||||
if (isAbsolutePath(path)) {
|
||||
return uri.with({ path: normalizePath(path.split('/')) });
|
||||
}
|
||||
return joinPath(uri, path);
|
||||
}
|
||||
|
||||
export function normalizePath(parts: string[]): string {
|
||||
const newParts: string[] = [];
|
||||
for (const part of parts) {
|
||||
if (part.length === 0 || part.length === 1 && part.charCodeAt(0) === Dot) {
|
||||
// ignore
|
||||
} else if (part.length === 2 && part.charCodeAt(0) === Dot && part.charCodeAt(1) === Dot) {
|
||||
newParts.pop();
|
||||
} else {
|
||||
newParts.push(part);
|
||||
}
|
||||
}
|
||||
if (parts.length > 1 && parts[parts.length - 1].length === 0) {
|
||||
newParts.push('');
|
||||
}
|
||||
let res = newParts.join('/');
|
||||
if (parts[0].length === 0) {
|
||||
res = '/' + res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
export function joinPath(uri: Uri, ...paths: string[]): Uri {
|
||||
const parts = uri.path.split('/');
|
||||
for (let path of paths) {
|
||||
parts.push(...path.split('/'));
|
||||
}
|
||||
return uri.with({ path: normalizePath(parts) });
|
||||
}
|
||||
|
Reference in New Issue
Block a user