mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode e6a45f4242ebddb7aa9a229f85555e8a3bd987e2 (#9253)
* Merge from vscode e6a45f4242ebddb7aa9a229f85555e8a3bd987e2 * skip failing tests * remove github-authentication extensions * ignore github compile steps * ignore github compile steps * check in compiled files
This commit is contained in:
@@ -25,7 +25,7 @@ export interface MarkdownRenderOptions extends FormattedTextRenderOptions {
|
||||
/**
|
||||
* Create html nodes for the given content element.
|
||||
*/
|
||||
export function renderMarkdown(markdown: IMarkdownString, options: MarkdownRenderOptions = {}): HTMLElement {
|
||||
export function renderMarkdown(markdown: IMarkdownString, options: MarkdownRenderOptions = {}, markedOptions: marked.MarkedOptions = {}): HTMLElement {
|
||||
const element = createElement(options);
|
||||
|
||||
const _uriMassage = function (part: string): string {
|
||||
@@ -183,10 +183,8 @@ export function renderMarkdown(markdown: IMarkdownString, options: MarkdownRende
|
||||
}));
|
||||
}
|
||||
|
||||
const markedOptions: marked.MarkedOptions = {
|
||||
sanitize: true,
|
||||
renderer
|
||||
};
|
||||
markedOptions.sanitize = true;
|
||||
markedOptions.renderer = renderer;
|
||||
|
||||
const allowedSchemes = [Schemas.http, Schemas.https, Schemas.mailto, Schemas.data, Schemas.file, Schemas.vscodeRemote, Schemas.vscodeRemoteResource];
|
||||
if (markdown.isTrusted) {
|
||||
|
||||
@@ -197,6 +197,7 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
|
||||
get contentHeight(): number { return this.rangeMap.size; }
|
||||
|
||||
get onDidScroll(): Event<ScrollEvent> { return this.scrollableElement.onScroll; }
|
||||
get onWillScroll(): Event<ScrollEvent> { return this.scrollableElement.onWillScroll; }
|
||||
|
||||
constructor(
|
||||
container: HTMLElement,
|
||||
|
||||
@@ -167,6 +167,9 @@ export abstract class AbstractScrollableElement extends Widget {
|
||||
private readonly _onScroll = this._register(new Emitter<ScrollEvent>());
|
||||
public readonly onScroll: Event<ScrollEvent> = this._onScroll.event;
|
||||
|
||||
private readonly _onWillScroll = this._register(new Emitter<ScrollEvent>());
|
||||
public readonly onWillScroll: Event<ScrollEvent> = this._onWillScroll.event;
|
||||
|
||||
protected constructor(element: HTMLElement, options: ScrollableElementCreationOptions, scrollable: Scrollable) {
|
||||
super();
|
||||
element.style.overflow = 'hidden';
|
||||
@@ -174,6 +177,7 @@ export abstract class AbstractScrollableElement extends Widget {
|
||||
this._scrollable = scrollable;
|
||||
|
||||
this._register(this._scrollable.onScroll((e) => {
|
||||
this._onWillScroll.fire(e);
|
||||
this._onDidScroll(e);
|
||||
this._onScroll.fire(e);
|
||||
}));
|
||||
|
||||
@@ -56,6 +56,20 @@ export function raceCancellation<T>(promise: Promise<T>, token: CancellationToke
|
||||
return Promise.race([promise, new Promise<T>(resolve => token.onCancellationRequested(() => resolve(defaultValue)))]);
|
||||
}
|
||||
|
||||
export function raceTimeout<T>(promise: Promise<T>, timeout: number, onTimeout?: () => void): Promise<T> {
|
||||
let promiseResolve: (() => void) | undefined = undefined;
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
promiseResolve?.();
|
||||
onTimeout?.();
|
||||
}, timeout);
|
||||
|
||||
return Promise.race([
|
||||
promise.finally(() => clearTimeout(timer)),
|
||||
new Promise<T>(resolve => promiseResolve = resolve)
|
||||
]);
|
||||
}
|
||||
|
||||
export function asPromise<T>(callback: () => T | Thenable<T>): Promise<T> {
|
||||
return new Promise<T>((resolve, reject) => {
|
||||
const item = callback();
|
||||
|
||||
@@ -13,7 +13,7 @@ const month = day * 30;
|
||||
const year = day * 365;
|
||||
|
||||
// TODO[ECA]: Localize strings
|
||||
export function fromNow(date: number | Date) {
|
||||
export function fromNow(date: number | Date, appendAgoLabel?: boolean): string {
|
||||
if (typeof date !== 'number') {
|
||||
date = date.getTime();
|
||||
}
|
||||
@@ -48,7 +48,7 @@ export function fromNow(date: number | Date) {
|
||||
unit = 'yr';
|
||||
}
|
||||
|
||||
return `${value} ${unit}${value === 1 ? '' : 's'}`;
|
||||
return `${value} ${unit}${value === 1 ? '' : 's'}${appendAgoLabel ? ' ago' : ''}`;
|
||||
|
||||
}
|
||||
|
||||
|
||||
24
src/vs/base/parts/composite/browser/compositeDnd.ts
Normal file
24
src/vs/base/parts/composite/browser/compositeDnd.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IDragAndDropData } from 'vs/base/browser/dnd';
|
||||
|
||||
export class CompositeDragAndDropData implements IDragAndDropData {
|
||||
constructor(private type: 'view' | 'composite', private id: string) { }
|
||||
update(dataTransfer: DataTransfer): void {
|
||||
// no-op
|
||||
}
|
||||
getData(): {
|
||||
type: 'view' | 'composite';
|
||||
id: string;
|
||||
} {
|
||||
return { type: this.type, id: this.id };
|
||||
}
|
||||
}
|
||||
|
||||
export interface ICompositeDragAndDrop {
|
||||
drop(data: IDragAndDropData, target: string | undefined, originalEvent: DragEvent): void;
|
||||
onDragOver(data: IDragAndDropData, target: string | undefined, originalEvent: DragEvent): boolean;
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import * as assert from 'assert';
|
||||
import * as async from 'vs/base/common/async';
|
||||
import { isPromiseCanceledError } from 'vs/base/common/errors';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
|
||||
suite('Async', () => {
|
||||
|
||||
@@ -646,4 +647,45 @@ suite('Async', () => {
|
||||
|
||||
assert.ok(pendingCancelled);
|
||||
});
|
||||
|
||||
test('raceCancellation', async () => {
|
||||
const cts = new CancellationTokenSource();
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
const p = async.raceCancellation(async.timeout(100), cts.token);
|
||||
cts.cancel();
|
||||
|
||||
await p;
|
||||
|
||||
assert.ok(Date.now() - now < 100);
|
||||
});
|
||||
|
||||
test('raceTimeout', async () => {
|
||||
const cts = new CancellationTokenSource();
|
||||
|
||||
// timeout wins
|
||||
let now = Date.now();
|
||||
let timedout = false;
|
||||
|
||||
const p1 = async.raceTimeout(async.timeout(100), 1, () => timedout = true);
|
||||
cts.cancel();
|
||||
|
||||
await p1;
|
||||
|
||||
assert.ok(Date.now() - now < 100);
|
||||
assert.equal(timedout, true);
|
||||
|
||||
// promise wins
|
||||
now = Date.now();
|
||||
timedout = false;
|
||||
|
||||
const p2 = async.raceTimeout(async.timeout(1), 100, () => timedout = true);
|
||||
cts.cancel();
|
||||
|
||||
await p2;
|
||||
|
||||
assert.ok(Date.now() - now < 100);
|
||||
assert.equal(timedout, false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user