mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)
* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 * fix pipelines * fix strict-null-checks * add missing files
This commit is contained in:
@@ -8,10 +8,11 @@ import { IURLService } from 'vs/platform/url/common/url';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { app, Event as ElectronEvent } from 'electron';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, DisposableStore, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IWindowsMainService } from 'vs/platform/windows/electron-main/windows';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { coalesce } from 'vs/base/common/arrays';
|
||||
import { disposableTimeout } from 'vs/base/common/async';
|
||||
|
||||
function uriFromRawUrl(url: string): URI | null {
|
||||
try {
|
||||
@@ -23,7 +24,10 @@ function uriFromRawUrl(url: string): URI | null {
|
||||
|
||||
export class ElectronURLListener {
|
||||
|
||||
private disposables: IDisposable[] = [];
|
||||
private uris: URI[] = [];
|
||||
private retryCount = 0;
|
||||
private flushDisposable: IDisposable = Disposable.None;
|
||||
private disposables = new DisposableStore();
|
||||
|
||||
constructor(
|
||||
initial: string | string[],
|
||||
@@ -36,12 +40,7 @@ export class ElectronURLListener {
|
||||
...globalBuffer
|
||||
];
|
||||
|
||||
const buffer = coalesce(rawBuffer.map(uriFromRawUrl));
|
||||
const flush = () => buffer.forEach(uri => {
|
||||
if (uri) {
|
||||
urlService.open(uri);
|
||||
}
|
||||
});
|
||||
this.uris = coalesce(rawBuffer.map(uriFromRawUrl));
|
||||
|
||||
if (isWindows) {
|
||||
app.setAsDefaultProtocolClient(product.urlProtocol, process.execPath, ['--open-url', '--']);
|
||||
@@ -63,13 +62,37 @@ export class ElectronURLListener {
|
||||
.length > 0;
|
||||
|
||||
if (isWindowReady) {
|
||||
flush();
|
||||
this.flush();
|
||||
} else {
|
||||
Event.once(windowsMainService.onWindowReady)(flush);
|
||||
Event.once(windowsMainService.onWindowReady)(this.flush, this, this.disposables);
|
||||
}
|
||||
}
|
||||
|
||||
private async flush(): Promise<void> {
|
||||
if (this.retryCount++ > 10) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uris: URI[] = [];
|
||||
|
||||
for (const uri of this.uris) {
|
||||
const handled = await this.urlService.open(uri);
|
||||
|
||||
if (!handled) {
|
||||
uris.push(uri);
|
||||
}
|
||||
}
|
||||
|
||||
if (uris.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.uris = uris;
|
||||
this.flushDisposable = disposableTimeout(() => this.flush(), 500);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.disposables = dispose(this.disposables);
|
||||
this.disposables.dispose();
|
||||
this.flushDisposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user