Merge VS Code 1.23.1 (#1520)

This commit is contained in:
Matt Irvine
2018-06-05 11:24:51 -07:00
committed by GitHub
parent e3baf5c443
commit 0c58f09e59
3651 changed files with 74249 additions and 48599 deletions

View File

@@ -5,23 +5,31 @@
'use strict';
import { TPromise } from 'vs/base/common/winjs.base';
import paths = require('vs/base/common/paths');
import * as paths from 'vs/base/common/paths';
import URI from 'vs/base/common/uri';
import glob = require('vs/base/common/glob');
import * as glob from 'vs/base/common/glob';
import { isLinux } from 'vs/base/common/platform';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import Event from 'vs/base/common/event';
import { beginsWithIgnoreCase } from 'vs/base/common/strings';
import { IProgress } from 'vs/platform/progress/common/progress';
import { Event } from 'vs/base/common/event';
import { startsWithIgnoreCase } from 'vs/base/common/strings';
import { IDisposable } from 'vs/base/common/lifecycle';
import { isEqualOrParent, isEqual } from 'vs/base/common/resources';
import { isUndefinedOrNull } from 'vs/base/common/types';
export const IFileService = createDecorator<IFileService>('fileService');
export interface IResourceEncodings {
getWriteEncoding(resource: URI, preferredEncoding?: string): string;
}
export interface IFileService {
_serviceBrand: any;
/**
* Helper to determine read/write encoding for resources.
*/
encoding: IResourceEncodings;
/**
* Allows to listen for file changes. The event will fire for every file within the opened workspace
* (if any) as well as all files that have been watched explicitly using the #watchFileChanges() API.
@@ -33,15 +41,20 @@ export interface IFileService {
*/
onAfterOperation: Event<FileOperationEvent>;
/**
* An event that is fired when a file system provider is added or removed
*/
onDidChangeFileSystemProviderRegistrations: Event<IFileSystemProviderRegistrationEvent>;
/**
* Registeres a file system provider for a certain scheme.
*/
registerProvider?(scheme: string, provider: IFileSystemProvider): IDisposable;
registerProvider(scheme: string, provider: IFileSystemProvider): IDisposable;
/**
* Checks if this file service can handle the given resource.
*/
canHandleResource?(resource: URI): boolean;
canHandleResource(resource: URI): boolean;
/**
* Resolve the properties of a file identified by the resource.
@@ -120,23 +133,12 @@ export interface IFileService {
*/
rename(resource: URI, newName: string): TPromise<IFileStat>;
/**
* Creates a new empty file if the given path does not exist and otherwise
* will set the mtime and atime of the file to the current date.
*/
touchFile(resource: URI): TPromise<IFileStat>;
/**
* Deletes the provided file. The optional useTrash parameter allows to
* move the file to trash.
*/
del(resource: URI, useTrash?: boolean): TPromise<void>;
/**
* Imports the file to the parent identified by the resource.
*/
importFile(source: URI, targetFolder: URI): TPromise<IImportResult>;
/**
* Allows to start a watcher that reports file change events on the provided resource.
*/
@@ -147,59 +149,83 @@ export interface IFileService {
*/
unwatchFileChanges(resource: URI): void;
/**
* Configures the file service with the provided options.
*/
updateOptions(options: object): void;
/**
* Returns the preferred encoding to use for a given resource.
*/
getEncoding(resource: URI, preferredEncoding?: string): string;
/**
* Frees up any resources occupied by this service.
*/
dispose(): void;
}
export interface FileOverwriteOptions {
overwrite: boolean;
}
export interface FileWriteOptions {
overwrite: boolean;
create: boolean;
}
export enum FileType {
File = 0,
Dir = 1,
Symlink = 2
Unknown = 0,
File = 1,
Directory = 2,
SymbolicLink = 64
}
export interface IStat {
id: number | string;
mtime: number;
size: number;
type: FileType;
mtime: number;
ctime: number;
size: number;
}
export interface IWatchOptions {
recursive: boolean;
excludes: string[];
}
export enum FileSystemProviderCapabilities {
FileReadWrite = 1 << 1,
FileOpenReadWriteClose = 1 << 2,
FileFolderCopy = 1 << 3,
PathCaseSensitive = 1 << 10
}
export interface IFileSystemProvider {
onDidChange?: Event<IFileChange[]>;
readonly capabilities: FileSystemProviderCapabilities;
onDidChangeFile: Event<IFileChange[]>;
watch(resource: URI, opts: IWatchOptions): IDisposable;
// more...
//
utimes(resource: URI, mtime: number, atime: number): TPromise<IStat>;
stat(resource: URI): TPromise<IStat>;
read(resource: URI, offset: number, count: number, progress: IProgress<Uint8Array>): TPromise<number>;
write(resource: URI, content: Uint8Array): TPromise<void>;
move(from: URI, to: URI): TPromise<IStat>;
mkdir(resource: URI): TPromise<IStat>;
readdir(resource: URI): TPromise<[URI, IStat][]>;
rmdir(resource: URI): TPromise<void>;
unlink(resource: URI): TPromise<void>;
mkdir(resource: URI): TPromise<void>;
readdir(resource: URI): TPromise<[string, FileType][]>;
delete(resource: URI): TPromise<void>;
rename(from: URI, to: URI, opts: FileOverwriteOptions): TPromise<void>;
copy?(from: URI, to: URI, opts: FileOverwriteOptions): TPromise<void>;
readFile?(resource: URI): TPromise<Uint8Array>;
writeFile?(resource: URI, content: Uint8Array, opts: FileWriteOptions): TPromise<void>;
open?(resource: URI): TPromise<number>;
close?(fd: number): TPromise<void>;
read?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): TPromise<number>;
write?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): TPromise<number>;
}
export interface IFileSystemProviderRegistrationEvent {
added: boolean;
scheme: string;
provider?: IFileSystemProvider;
}
export enum FileOperation {
CREATE,
DELETE,
MOVE,
COPY,
IMPORT
COPY
}
export class FileOperationEvent {
@@ -348,31 +374,12 @@ export function isParent(path: string, candidate: string, ignoreCase?: boolean):
}
if (ignoreCase) {
return beginsWithIgnoreCase(path, candidate);
return startsWithIgnoreCase(path, candidate);
}
return path.indexOf(candidate) === 0;
}
export function indexOf(path: string, candidate: string, ignoreCase?: boolean): number {
if (candidate.length > path.length) {
return -1;
}
if (path === candidate) {
return 0;
}
if (ignoreCase) {
path = path.toLowerCase();
candidate = candidate.toLowerCase();
}
return path.indexOf(candidate);
}
export interface IBaseStat {
/**
@@ -474,6 +481,14 @@ export interface ITextSnapshot {
read(): string;
}
export class StringSnapshot implements ITextSnapshot {
constructor(private _value: string) { }
read(): string {
let ret = this._value;
this._value = null;
return ret;
}
}
/**
* Helper method to convert a snapshot into its full string form.
*/
@@ -512,9 +527,10 @@ export interface IResolveContentOptions {
acceptTextOnly?: boolean;
/**
* The optional etag parameter allows to return a 304 (Not Modified) if the etag matches
* with the remote resource. It is the task of the caller to makes sure to handle this
* error case from the promise.
* The optional etag parameter allows to return early from resolving the resource if
* the contents on disk match the etag. This prevents accumulated reading of resources
* that have been read already with the same etag.
* It is the task of the caller to makes sure to handle this error case from the promise.
*/
etag?: string;
@@ -568,6 +584,11 @@ export interface IUpdateContentOptions {
* The etag of the file. This can be used to prevent dirty writes.
*/
etag?: string;
/**
* Run mkdirp before saving.
*/
mkdirp?: boolean;
}
export interface IResolveFileOptions {
@@ -584,11 +605,6 @@ export interface ICreateFileOptions {
overwrite?: boolean;
}
export interface IImportResult {
stat: IFileStat;
isNew: boolean;
}
export class FileOperationError extends Error {
constructor(message: string, public fileOperationResult: FileOperationResult, public options?: IResolveContentOptions & IUpdateContentOptions & ICreateFileOptions) {
super(message);

View File

@@ -8,7 +8,7 @@
import * as assert from 'assert';
import URI from 'vs/base/common/uri';
import { join, isEqual, isEqualOrParent } from 'vs/base/common/paths';
import { FileChangeType, FileChangesEvent, isParent, indexOf } from 'vs/platform/files/common/files';
import { FileChangeType, FileChangesEvent, isParent } from 'vs/platform/files/common/files';
import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
suite('Files', () => {
@@ -187,16 +187,4 @@ suite('Files', () => {
assert(!isEqualOrParent('foo/bar/test.ts', 'foo/BAR/test.', true));
}
});
test('indexOf (ignorecase)', function () {
assert.equal(indexOf('/some/path', '/some/path', true), 0);
assert.equal(indexOf('/some/path/more', '/some/path', true), 0);
assert.equal(indexOf('c:\\some\\path', 'c:\\some\\path', true), 0);
assert.equal(indexOf('c:\\some\\path\\more', 'c:\\some\\path', true), 0);
assert.equal(indexOf('/some/path', '/some/other/path', true), -1);
assert.equal(indexOf('/some/path', '/some/PATH', true), 0);
});
});