Merge from vscode cfc1ab4c5f816765b91fb7ead3c3427a7c8581a3

This commit is contained in:
ADS Merger
2020-03-11 04:19:23 +00:00
parent 16fab722d5
commit 4c3e48773d
880 changed files with 20441 additions and 11232 deletions

View File

@@ -14,7 +14,7 @@ export function isFalsyOrWhitespace(str: string | undefined): boolean {
}
/**
* @returns the provided number with the given number of preceding zeros.
* @deprecated ES6: use `String.padStart`
*/
export function pad(n: number, l: number, char: string = '0'): string {
const str = '' + n;
@@ -145,7 +145,7 @@ export function stripWildcards(pattern: string): string {
}
/**
* Determines if haystack starts with needle.
* @deprecated ES6: use `String.startsWith`
*/
export function startsWith(haystack: string, needle: string): boolean {
if (haystack.length < needle.length) {
@@ -166,7 +166,7 @@ export function startsWith(haystack: string, needle: string): boolean {
}
/**
* Determines if haystack ends with needle.
* @deprecated ES6: use `String.endsWith`
*/
export function endsWith(haystack: string, needle: string): boolean {
const diff = haystack.length - needle.length;
@@ -240,7 +240,7 @@ export function regExpFlags(regexp: RegExp): string {
return (regexp.global ? 'g' : '')
+ (regexp.ignoreCase ? 'i' : '')
+ (regexp.multiline ? 'm' : '')
+ ((regexp as any).unicode ? 'u' : '');
+ ((regexp as any /* standalone editor compilation */).unicode ? 'u' : '');
}
/**
@@ -428,43 +428,6 @@ export function commonSuffixLength(a: string, b: string): number {
return len;
}
function substrEquals(a: string, aStart: number, aEnd: number, b: string, bStart: number, bEnd: number): boolean {
while (aStart < aEnd && bStart < bEnd) {
if (a[aStart] !== b[bStart]) {
return false;
}
aStart += 1;
bStart += 1;
}
return true;
}
/**
* Return the overlap between the suffix of `a` and the prefix of `b`.
* For instance `overlap("foobar", "arr, I'm a pirate") === 2`.
*/
export function overlap(a: string, b: string): number {
const aEnd = a.length;
let bEnd = b.length;
let aStart = aEnd - bEnd;
if (aStart === 0) {
return a === b ? aEnd : 0;
} else if (aStart < 0) {
bEnd += aStart;
aStart = 0;
}
while (aStart < aEnd && bEnd > 0) {
if (substrEquals(a, aStart, aEnd, b, 0, bEnd)) {
return bEnd;
}
bEnd -= 1;
aStart += 1;
}
return 0;
}
// --- unicode
// http://en.wikipedia.org/wiki/Surrogate_pair
// Returns the code point starting at a specified index in a string
@@ -852,21 +815,6 @@ export function removeAnsiEscapeCodes(str: string): string {
return str;
}
export const removeAccents: (str: string) => string = (function () {
if (typeof (String.prototype as any).normalize !== 'function') {
// ☹️ no ES6 features...
return function (str: string) { return str; };
} else {
// transform into NFD form and remove accents
// see: https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript/37511463#37511463
const regex = /[\u0300-\u036f]/g;
return function (str: string) {
return (str as any).normalize('NFD').replace(regex, '');
};
}
})();
// -- UTF-8 BOM
export const UTF8_BOM_CHARACTER = String.fromCharCode(CharCode.UTF8_BOM);