mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 2c306f762bf9c3db82dc06c7afaa56ef46d72f79 (#14050)
* Merge from vscode 2c306f762bf9c3db82dc06c7afaa56ef46d72f79 * Fix breaks * Extension management fixes * Fix breaks in windows bundling * Fix/skip failing tests * Update distro * Add clear to nuget.config * Add hygiene task * Bump distro * Fix hygiene issue * Add build to hygiene exclusion * Update distro * Update hygiene * Hygiene exclusions * Update tsconfig * Bump distro for server breaks * Update build config * Update darwin path * Add done calls to notebook tests * Skip failing tests * Disable smoke tests
This commit is contained in:
@@ -13,20 +13,6 @@ export function isFalsyOrWhitespace(str: string | undefined): boolean {
|
||||
return str.trim().length === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated ES6: use `String.padStart`
|
||||
*/
|
||||
export function pad(n: number, l: number, char: string = '0'): string {
|
||||
const str = '' + n;
|
||||
const r = [str];
|
||||
|
||||
for (let i = str.length; i < l; i++) {
|
||||
r.push(char);
|
||||
}
|
||||
|
||||
return r.reverse().join('');
|
||||
}
|
||||
|
||||
const _formatRegexp = /{(\d+)}/g;
|
||||
|
||||
/**
|
||||
@@ -69,6 +55,28 @@ export function escapeRegExpCharacters(value: string): string {
|
||||
return value.replace(/[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g, '\\$&');
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts how often `character` occurs inside `value`.
|
||||
*/
|
||||
export function count(value: string, character: string): number {
|
||||
let result = 0;
|
||||
const ch = character.charCodeAt(0);
|
||||
for (let i = value.length - 1; i >= 0; i--) {
|
||||
if (value.charCodeAt(i) === ch) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function truncate(value: string, maxLength: number, suffix = '…'): string {
|
||||
if (value.length <= maxLength) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return `${value.substr(0, maxLength)}${suffix}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all occurrences of needle from the beginning and end of haystack.
|
||||
* @param haystack string to trim
|
||||
@@ -243,6 +251,10 @@ export function regExpFlags(regexp: RegExp): string {
|
||||
+ ((regexp as any /* standalone editor compilation */).unicode ? 'u' : '');
|
||||
}
|
||||
|
||||
export function splitLines(str: string): string[] {
|
||||
return str.split(/\r\n|\r|\n/);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns first index of the string that is not whitespace.
|
||||
* If string is empty or contains only whitespaces, returns -1
|
||||
@@ -855,6 +867,7 @@ export function stripUTF8BOM(str: string): string {
|
||||
return startsWithUTF8BOM(str) ? str.substr(1) : str;
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
/**
|
||||
* @deprecated ES6
|
||||
*/
|
||||
@@ -925,9 +938,15 @@ export function getNLines(str: string, n = 1): string {
|
||||
n--;
|
||||
} while (n > 0 && idx >= 0);
|
||||
|
||||
return idx >= 0 ?
|
||||
str.substr(0, idx) :
|
||||
str;
|
||||
if (idx === -1) {
|
||||
return str;
|
||||
}
|
||||
|
||||
if (str[idx - 1] === '\r') {
|
||||
idx--;
|
||||
}
|
||||
|
||||
return str.substr(0, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user