Merge VS Code 1.31.1 (#4283)

This commit is contained in:
Matt Irvine
2019-03-15 13:09:45 -07:00
committed by GitHub
parent 7d31575149
commit 86bac90001
1716 changed files with 53308 additions and 48375 deletions

View File

@@ -13,20 +13,20 @@ export const MIME_BINARY = 'application/octet-stream';
export const MIME_UNKNOWN = 'application/unknown';
export interface ITextMimeAssociation {
id: string;
mime: string;
filename?: string;
extension?: string;
filepattern?: string;
firstline?: RegExp;
userConfigured?: boolean;
readonly id: string;
readonly mime: string;
readonly filename?: string;
readonly extension?: string;
readonly filepattern?: string;
readonly firstline?: RegExp;
readonly userConfigured?: boolean;
}
interface ITextMimeAssociationItem extends ITextMimeAssociation {
filenameLowercase?: string;
extensionLowercase?: string;
filepatternLowercase?: string;
filepatternOnPath?: boolean;
readonly filenameLowercase?: string;
readonly extensionLowercase?: string;
readonly filepatternLowercase?: string;
readonly filepatternOnPath?: boolean;
}
let registeredAssociations: ITextMimeAssociationItem[] = [];
@@ -82,9 +82,9 @@ function toTextMimeAssociationItem(association: ITextMimeAssociation): ITextMime
filepattern: association.filepattern,
firstline: association.firstline,
userConfigured: association.userConfigured,
filenameLowercase: association.filename ? association.filename.toLowerCase() : void 0,
extensionLowercase: association.extension ? association.extension.toLowerCase() : void 0,
filepatternLowercase: association.filepattern ? association.filepattern.toLowerCase() : void 0,
filenameLowercase: association.filename ? association.filename.toLowerCase() : undefined,
extensionLowercase: association.extension ? association.extension.toLowerCase() : undefined,
filepatternLowercase: association.filepattern ? association.filepattern.toLowerCase() : undefined,
filepatternOnPath: association.filepattern ? association.filepattern.indexOf(paths.sep) >= 0 : false
};
}
@@ -106,7 +106,7 @@ export function clearTextMimes(onlyUserConfigured?: boolean): void {
/**
* Given a file, return the best matching mime type for it
*/
export function guessMimeTypes(path: string, firstLine?: string, skipUserAssociations: boolean = false): string[] {
export function guessMimeTypes(path: string | null, firstLine?: string): string[] {
if (!path) {
return [MIME_UNKNOWN];
}
@@ -114,12 +114,10 @@ export function guessMimeTypes(path: string, firstLine?: string, skipUserAssocia
path = path.toLowerCase();
const filename = paths.basename(path);
if (!skipUserAssociations) {
// 1.) User configured mappings have highest priority
const configuredMime = guessMimeTypeByPath(path, filename, userRegisteredAssociations);
if (configuredMime) {
return [configuredMime, MIME_TEXT];
}
// 1.) User configured mappings have highest priority
const configuredMime = guessMimeTypeByPath(path, filename, userRegisteredAssociations);
if (configuredMime) {
return [configuredMime, MIME_TEXT];
}
// 2.) Registered mappings have middle priority
@@ -199,8 +197,7 @@ function guessMimeTypeByFirstline(firstLine: string): string | null {
}
if (firstLine.length > 0) {
for (let i = 0; i < registeredAssociations.length; ++i) {
const association = registeredAssociations[i];
for (const association of registeredAssociations) {
if (!association.firstline) {
continue;
}