mirror of
https://github.com/coder/code-server.git
synced 2026-05-29 08:29:33 +00:00
Update to VS Code 1.52.1
This commit is contained in:
@@ -69,6 +69,14 @@ export function count(value: string, character: string): number {
|
||||
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
|
||||
@@ -208,6 +216,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
|
||||
@@ -879,9 +891,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