mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge VS Code 1.31.1 (#4283)
This commit is contained in:
@@ -10,12 +10,12 @@ import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
export const IURLService = createDecorator<IURLService>('urlService');
|
||||
|
||||
export interface IURLHandler {
|
||||
handleURL(uri: URI): Thenable<boolean>;
|
||||
handleURL(uri: URI): Promise<boolean>;
|
||||
}
|
||||
|
||||
export interface IURLService {
|
||||
_serviceBrand: any;
|
||||
|
||||
open(url: URI): Thenable<boolean>;
|
||||
open(url: URI): Promise<boolean>;
|
||||
registerHandler(handler: IURLHandler): IDisposable;
|
||||
}
|
||||
|
||||
@@ -7,10 +7,7 @@ import { IURLService, IURLHandler } from 'vs/platform/url/common/url';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { first } from 'vs/base/common/async';
|
||||
|
||||
declare module Array {
|
||||
function from<T>(set: Set<T>): T[];
|
||||
}
|
||||
import { values } from 'vs/base/common/map';
|
||||
|
||||
export class URLService implements IURLService {
|
||||
|
||||
@@ -18,9 +15,9 @@ export class URLService implements IURLService {
|
||||
|
||||
private handlers = new Set<IURLHandler>();
|
||||
|
||||
open(uri: URI): Thenable<boolean> {
|
||||
const handlers = Array.from(this.handlers);
|
||||
return first(handlers.map(h => () => h.handleURL(uri)), undefined, false);
|
||||
open(uri: URI): Promise<boolean> {
|
||||
const handlers = values(this.handlers);
|
||||
return first(handlers.map(h => () => h.handleURL(uri)), undefined, false).then(val => val || false);
|
||||
}
|
||||
|
||||
registerHandler(handler: IURLHandler): IDisposable {
|
||||
@@ -35,11 +32,11 @@ export class RelayURLService extends URLService implements IURLHandler {
|
||||
super();
|
||||
}
|
||||
|
||||
open(uri: URI): Thenable<boolean> {
|
||||
open(uri: URI): Promise<boolean> {
|
||||
return this.urlService.open(uri);
|
||||
}
|
||||
|
||||
handleURL(uri: URI): Thenable<boolean> {
|
||||
handleURL(uri: URI): Promise<boolean> {
|
||||
return super.open(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { mapEvent, fromNodeEventEmitter, filterEvent, once } from 'vs/base/common/event';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IURLService } from 'vs/platform/url/common/url';
|
||||
import product from 'vs/platform/node/product';
|
||||
import { app } from 'electron';
|
||||
@@ -11,6 +11,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
import { IDisposable, dispose } 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';
|
||||
|
||||
function uriFromRawUrl(url: string): URI | null {
|
||||
try {
|
||||
@@ -26,7 +27,7 @@ export class ElectronURLListener {
|
||||
|
||||
constructor(
|
||||
initial: string | string[],
|
||||
@IURLService private urlService: IURLService,
|
||||
@IURLService private readonly urlService: IURLService,
|
||||
@IWindowsMainService windowsService: IWindowsMainService
|
||||
) {
|
||||
const globalBuffer = ((<any>global).getOpenUrls() || []) as string[];
|
||||
@@ -35,7 +36,7 @@ export class ElectronURLListener {
|
||||
...globalBuffer
|
||||
];
|
||||
|
||||
const buffer = rawBuffer.map(uriFromRawUrl).filter(uri => !!uri);
|
||||
const buffer = coalesce(rawBuffer.map(uriFromRawUrl));
|
||||
const flush = () => buffer.forEach(uri => {
|
||||
if (uri) {
|
||||
urlService.open(uri);
|
||||
@@ -46,15 +47,15 @@ export class ElectronURLListener {
|
||||
app.setAsDefaultProtocolClient(product.urlProtocol, process.execPath, ['--open-url', '--']);
|
||||
}
|
||||
|
||||
const onOpenElectronUrl = mapEvent(
|
||||
fromNodeEventEmitter(app, 'open-url', (event: Electron.Event, url: string) => ({ event, url })),
|
||||
const onOpenElectronUrl = Event.map(
|
||||
Event.fromNodeEventEmitter(app, 'open-url', (event: Electron.Event, url: string) => ({ event, url })),
|
||||
({ event, url }) => {
|
||||
// always prevent default and return the url as string
|
||||
event.preventDefault();
|
||||
return url;
|
||||
});
|
||||
|
||||
const onOpenUrl = filterEvent(mapEvent(onOpenElectronUrl, uriFromRawUrl), uri => !!uri);
|
||||
const onOpenUrl = Event.filter(Event.map(onOpenElectronUrl, uriFromRawUrl), uri => !!uri);
|
||||
onOpenUrl(this.urlService.open, this.urlService, this.disposables);
|
||||
|
||||
const isWindowReady = windowsService.getWindows()
|
||||
@@ -64,7 +65,7 @@ export class ElectronURLListener {
|
||||
if (isWindowReady) {
|
||||
flush();
|
||||
} else {
|
||||
once(windowsService.onWindowReady)(flush);
|
||||
Event.once(windowsService.onWindowReady)(flush);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ export class URLServiceChannel implements IServerChannel {
|
||||
throw new Error(`Event not found: ${event}`);
|
||||
}
|
||||
|
||||
call(_, command: string, arg?: any): Thenable<any> {
|
||||
call(_, command: string, arg?: any): Promise<any> {
|
||||
switch (command) {
|
||||
case 'open': return this.service.open(URI.revive(arg));
|
||||
}
|
||||
@@ -32,7 +32,7 @@ export class URLServiceChannelClient implements IURLService {
|
||||
|
||||
constructor(private channel: IChannel) { }
|
||||
|
||||
open(url: URI): Thenable<boolean> {
|
||||
open(url: URI): Promise<boolean> {
|
||||
return this.channel.call('open', url.toJSON());
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export class URLHandlerChannel implements IServerChannel {
|
||||
throw new Error(`Event not found: ${event}`);
|
||||
}
|
||||
|
||||
call(_, command: string, arg?: any): Thenable<any> {
|
||||
call(_, command: string, arg?: any): Promise<any> {
|
||||
switch (command) {
|
||||
case 'handleURL': return this.handler.handleURL(URI.revive(arg));
|
||||
}
|
||||
@@ -62,7 +62,7 @@ export class URLHandlerChannelClient implements IURLHandler {
|
||||
|
||||
constructor(private channel: IChannel) { }
|
||||
|
||||
handleURL(uri: URI): Thenable<boolean> {
|
||||
handleURL(uri: URI): Promise<boolean> {
|
||||
return this.channel.call('handleURL', uri.toJSON());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user