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

@@ -34,7 +34,7 @@ import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/commo
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { WORKSPACE_EXTENSION } from 'vs/platform/workspaces/common/workspaces';
import { UTF8, UTF8_with_bom, UTF16be, UTF16le, encodingExists, UTF8_BOM, detectEncodingByBOMFromBuffer, toEncodeReadable, toDecodeStream, IDecodeStreamResult } from 'vs/workbench/services/textfile/common/encoding';
import { UTF8, UTF8_with_bom, UTF16be, UTF16le, encodingExists, toEncodeReadable, toDecodeStream, IDecodeStreamResult } from 'vs/workbench/services/textfile/common/encoding';
import { consumeStream } from 'vs/base/common/stream';
import { IModeService } from 'vs/editor/common/services/modeService';
import { ILogService } from 'vs/platform/log/common/log';
@@ -459,7 +459,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
// Try to place where last active file was if any
// Otherwise fallback to user home
return joinPath(this.fileDialogService.defaultFilePath() || (await this.pathService.userHome()), suggestedFilename);
return joinPath(await this.fileDialogService.defaultFilePath(), suggestedFilename);
}
suggestFilename(mode: string, untitledName: string) {
@@ -532,7 +532,6 @@ export class EncodingOracle extends Disposable implements IResourceEncodings {
@ITextResourceConfigurationService private textResourceConfigurationService: ITextResourceConfigurationService,
@IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IFileService private fileService: IFileService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
) {
super();
@@ -569,26 +568,7 @@ export class EncodingOracle extends Disposable implements IResourceEncodings {
async getWriteEncoding(resource: URI, options?: IWriteTextFileOptions): Promise<{ encoding: string, addBOM: boolean }> {
const { encoding, hasBOM } = await this.getPreferredWriteEncoding(resource, options ? options.encoding : undefined);
// Some encodings come with a BOM automatically
if (hasBOM) {
return { encoding, addBOM: true };
}
// Ensure that we preserve an existing BOM if found for UTF8
// unless we are instructed to overwrite the encoding
const overwriteEncoding = options?.overwriteEncoding;
if (!overwriteEncoding && encoding === UTF8) {
try {
const buffer = (await this.fileService.readFile(resource, { length: UTF8_BOM.length })).value;
if (detectEncodingByBOMFromBuffer(buffer, buffer.byteLength) === UTF8_with_bom) {
return { encoding, addBOM: true };
}
} catch (error) {
// ignore - file might not exist
}
}
return { encoding, addBOM: false };
return { encoding, addBOM: hasBOM };
}
async getPreferredWriteEncoding(resource: URI, preferredEncoding?: string): Promise<IResourceEncoding> {

View File

@@ -810,7 +810,6 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
try {
const stat = await this.textFileService.write(lastResolvedFileStat.resource, textFileEditorModel.createSnapshot(), {
overwriteReadonly: options.overwriteReadonly,
overwriteEncoding: options.overwriteEncoding,
mtime: lastResolvedFileStat.mtime,
encoding: this.getEncoding(),
etag: (options.ignoreModifiedSince || !this.filesConfigurationService.preventSaveConflicts(lastResolvedFileStat.resource, textFileEditorModel.getMode())) ? ETAG_DISABLED : lastResolvedFileStat.etag,
@@ -978,7 +977,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
}
if (!this.inConflictMode) {
this.save({ overwriteEncoding: true });
this.save();
}
}

View File

@@ -124,11 +124,6 @@ export interface IWriteTextFileOptions extends IWriteFileOptions {
*/
encoding?: string;
/**
* If set to true, will enforce the selected encoding and not perform any detection using BOMs.
*/
overwriteEncoding?: boolean;
/**
* Whether to overwrite a file even if it is readonly.
*/
@@ -370,11 +365,6 @@ export interface ITextFileSaveOptions extends ISaveOptions {
*/
overwriteReadonly?: boolean;
/**
* Overwrite the encoding of the file on disk as configured.
*/
overwriteEncoding?: boolean;
/**
* Save the file with elevated privileges.
*

View File

@@ -8,7 +8,7 @@ import { AbstractTextFileService } from 'vs/workbench/services/textfile/browser/
import { ITextFileService, ITextFileStreamContent, ITextFileContent, IReadTextFileOptions, IWriteTextFileOptions } from 'vs/workbench/services/textfile/common/textfiles';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { URI } from 'vs/base/common/uri';
import { IFileStatWithMetadata, FileOperationError, FileOperationResult, IFileService } from 'vs/platform/files/common/files';
import { IFileStatWithMetadata, FileOperationError, FileOperationResult, IFileService, ByteSize } from 'vs/platform/files/common/files';
import { Schemas } from 'vs/base/common/network';
import { stat, chmod, MAX_FILE_SIZE, MAX_HEAP_SIZE } from 'vs/base/node/pfs';
import { join } from 'vs/base/common/path';
@@ -96,7 +96,7 @@ export class NativeTextFileService extends AbstractTextFileService {
const maxMemory = this.environmentService.args['max-memory'];
ensuredLimits.memory = Math.max(
typeof maxMemory === 'string'
? parseInt(maxMemory) * 1024 * 1024 || 0
? parseInt(maxMemory) * ByteSize.MB || 0
: 0, MAX_HEAP_SIZE
);
}

View File

@@ -310,13 +310,13 @@ export default function createSuite(params: Params) {
detectedEncoding = await detectEncodingByBOM(resource.fsPath);
assert.equal(detectedEncoding, UTF8_with_bom);
// ensure BOM preserved
await service.write(resource, content, { encoding: UTF8 });
// ensure BOM preserved if enforced
await service.write(resource, content, { encoding: UTF8_with_bom });
detectedEncoding = await detectEncodingByBOM(resource.fsPath);
assert.equal(detectedEncoding, UTF8_with_bom);
// allow to remove BOM
await service.write(resource, content, { encoding: UTF8, overwriteEncoding: true });
await service.write(resource, content, { encoding: UTF8 });
detectedEncoding = await detectEncodingByBOM(resource.fsPath);
assert.equal(detectedEncoding, null);
@@ -338,13 +338,13 @@ export default function createSuite(params: Params) {
detectedEncoding = await detectEncodingByBOM(resource.fsPath);
assert.equal(detectedEncoding, UTF8_with_bom);
// ensure BOM preserved
await service.write(resource, model.createSnapshot(), { encoding: UTF8 });
// ensure BOM preserved if enforced
await service.write(resource, model.createSnapshot(), { encoding: UTF8_with_bom });
detectedEncoding = await detectEncodingByBOM(resource.fsPath);
assert.equal(detectedEncoding, UTF8_with_bom);
// allow to remove BOM
await service.write(resource, model.createSnapshot(), { encoding: UTF8, overwriteEncoding: true });
await service.write(resource, model.createSnapshot(), { encoding: UTF8 });
detectedEncoding = await detectEncodingByBOM(resource.fsPath);
assert.equal(detectedEncoding, null);
@@ -360,7 +360,7 @@ export default function createSuite(params: Params) {
let detectedEncoding = await detectEncodingByBOM(resource.fsPath);
assert.equal(detectedEncoding, UTF8_with_bom);
await service.write(resource, 'Hello World');
await service.write(resource, 'Hello World', { encoding: detectedEncoding! });
detectedEncoding = await detectEncodingByBOM(resource.fsPath);
assert.equal(detectedEncoding, UTF8_with_bom);
});