mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode cbeff45f80213db0ddda2183170281ed97ed3b12 (#8670)
* Merge from vscode cbeff45f80213db0ddda2183170281ed97ed3b12 * fix null strict checks
This commit is contained in:
@@ -184,13 +184,14 @@ export class Delayer<T> implements IDisposable {
|
||||
private timeout: any;
|
||||
private completionPromise: Promise<any> | null;
|
||||
private doResolve: ((value?: any | Promise<any>) => void) | null;
|
||||
private doReject?: (err: any) => void;
|
||||
private doReject: ((err: any) => void) | null;
|
||||
private task: ITask<T | Promise<T>> | null;
|
||||
|
||||
constructor(public defaultDelay: number) {
|
||||
this.timeout = null;
|
||||
this.completionPromise = null;
|
||||
this.doResolve = null;
|
||||
this.doReject = null;
|
||||
this.task = null;
|
||||
}
|
||||
|
||||
@@ -205,16 +206,20 @@ export class Delayer<T> implements IDisposable {
|
||||
}).then(() => {
|
||||
this.completionPromise = null;
|
||||
this.doResolve = null;
|
||||
const task = this.task!;
|
||||
this.task = null;
|
||||
|
||||
return task();
|
||||
if (this.task) {
|
||||
const task = this.task;
|
||||
this.task = null;
|
||||
return task();
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
|
||||
this.timeout = setTimeout(() => {
|
||||
this.timeout = null;
|
||||
this.doResolve!(null);
|
||||
if (this.doResolve) {
|
||||
this.doResolve(null);
|
||||
}
|
||||
}, delay);
|
||||
|
||||
return this.completionPromise;
|
||||
@@ -228,7 +233,9 @@ export class Delayer<T> implements IDisposable {
|
||||
this.cancelTimeout();
|
||||
|
||||
if (this.completionPromise) {
|
||||
this.doReject!(errors.canceled());
|
||||
if (this.doReject) {
|
||||
this.doReject(errors.canceled());
|
||||
}
|
||||
this.completionPromise = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const escapeCodiconsRegex = /(?<!\\)\$\([a-z0-9\-]+?(?:~[a-z0-9\-]*?)?\)/gi;
|
||||
const escapeCodiconsRegex = /(\\)?\$\([a-z0-9\-]+?(?:~[a-z0-9\-]*?)?\)/gi;
|
||||
export function escapeCodicons(text: string): string {
|
||||
return text.replace(escapeCodiconsRegex, match => `\\${match}`);
|
||||
return text.replace(escapeCodiconsRegex, (match, escaped) => escaped ? match : `\\${match}`);
|
||||
}
|
||||
|
||||
const markdownEscapedCodiconsRegex = /\\\$\([a-z0-9\-]+?(?:~[a-z0-9\-]*?)?\)/gi;
|
||||
@@ -14,15 +14,15 @@ export function markdownEscapeEscapedCodicons(text: string): string {
|
||||
return text.replace(markdownEscapedCodiconsRegex, match => `\\${match}`);
|
||||
}
|
||||
|
||||
const markdownUnescapeCodiconsRegex = /(?<!\\)\$\\\(([a-z0-9\-]+?(?:~[a-z0-9\-]*?)?)\\\)/gi;
|
||||
const markdownUnescapeCodiconsRegex = /(\\)?\$\\\(([a-z0-9\-]+?(?:~[a-z0-9\-]*?)?)\\\)/gi;
|
||||
export function markdownUnescapeCodicons(text: string): string {
|
||||
return text.replace(markdownUnescapeCodiconsRegex, (_, codicon) => `$(${codicon})`);
|
||||
return text.replace(markdownUnescapeCodiconsRegex, (match, escaped, codicon) => escaped ? match : `$(${codicon})`);
|
||||
}
|
||||
|
||||
const renderCodiconsRegex = /(\\)?\$\((([a-z0-9\-]+?)(?:~([a-z0-9\-]*?))?)\)/gi;
|
||||
export function renderCodicons(text: string): string {
|
||||
return text.replace(renderCodiconsRegex, (_, escape, codicon, name, animation) => {
|
||||
return escape
|
||||
return text.replace(renderCodiconsRegex, (_, escaped, codicon, name, animation) => {
|
||||
return escaped
|
||||
? `$(${codicon})`
|
||||
: `<span class="codicon codicon-${name}${animation ? ` codicon-animation-${animation}` : ''}"></span>`;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user