mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 19:18:32 -05:00
Merge from vscode 2b0b9136329c181a9e381463a1f7dc3a2d105a34 (#4880)
This commit is contained in:
@@ -16,6 +16,7 @@ import { LogLevel } from 'vs/platform/log/common/log';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { CancelablePromise, createCancelablePromise } from 'vs/base/common/async';
|
||||
|
||||
export const IWindowsService = createDecorator<IWindowsService>('windowsService');
|
||||
|
||||
@@ -23,7 +24,7 @@ export interface INativeOpenDialogOptions {
|
||||
windowId?: number;
|
||||
forceNewWindow?: boolean;
|
||||
|
||||
dialogOptions?: OpenDialogOptions;
|
||||
defaultPath?: string;
|
||||
|
||||
telemetryEventName?: string;
|
||||
telemetryExtraData?: ITelemetryData;
|
||||
@@ -179,7 +180,6 @@ export interface IMessageBoxResult {
|
||||
export interface IOpenSettings {
|
||||
forceNewWindow?: boolean;
|
||||
forceReuseWindow?: boolean;
|
||||
forceOpenWorkspaceAsFile?: boolean;
|
||||
diffMode?: boolean;
|
||||
addMode?: boolean;
|
||||
noRecentEntry?: boolean;
|
||||
@@ -187,14 +187,36 @@ export interface IOpenSettings {
|
||||
args?: ParsedArgs;
|
||||
}
|
||||
|
||||
export type URIType = 'file' | 'folder';
|
||||
export type IURIToOpen = IWorkspaceToOpen | IFolderToOpen | IFileToOpen;
|
||||
|
||||
export interface IURIToOpen {
|
||||
uri: URI;
|
||||
typeHint?: URIType;
|
||||
export interface IWorkspaceToOpen {
|
||||
workspaceUri: URI;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
export interface IFolderToOpen {
|
||||
folderUri: URI;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
export interface IFileToOpen {
|
||||
fileUri: URI;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
export function isWorkspaceToOpen(uriToOpen: IURIToOpen): uriToOpen is IWorkspaceToOpen {
|
||||
return !!uriToOpen['workspaceUri'];
|
||||
}
|
||||
|
||||
export function isFolderToOpen(uriToOpen: IURIToOpen): uriToOpen is IFolderToOpen {
|
||||
return !!uriToOpen['folderUri'];
|
||||
}
|
||||
|
||||
export function isFileToOpen(uriToOpen: IURIToOpen): uriToOpen is IFileToOpen {
|
||||
return !!uriToOpen['fileUri'];
|
||||
}
|
||||
|
||||
|
||||
export interface IWindowService {
|
||||
|
||||
_serviceBrand: any;
|
||||
@@ -428,31 +450,31 @@ export interface IRunKeybindingInWindowRequest {
|
||||
export class ActiveWindowManager implements IDisposable {
|
||||
|
||||
private disposables: IDisposable[] = [];
|
||||
private firstActiveWindowIdPromise: Promise<any> | null;
|
||||
private _activeWindowId: number | undefined;
|
||||
private firstActiveWindowIdPromise: CancelablePromise<number | undefined> | undefined;
|
||||
private activeWindowId: number | undefined;
|
||||
|
||||
constructor(@IWindowsService windowsService: IWindowsService) {
|
||||
const onActiveWindowChange = Event.latch(Event.any(windowsService.onWindowOpen, windowsService.onWindowFocus));
|
||||
onActiveWindowChange(this.setActiveWindow, this, this.disposables);
|
||||
|
||||
this.firstActiveWindowIdPromise = windowsService.getActiveWindowId()
|
||||
.then(id => (typeof this._activeWindowId === 'undefined') && this.setActiveWindow(id));
|
||||
this.firstActiveWindowIdPromise = createCancelablePromise(_ => windowsService.getActiveWindowId());
|
||||
this.firstActiveWindowIdPromise
|
||||
.then(id => this.activeWindowId = id)
|
||||
.finally(this.firstActiveWindowIdPromise = undefined);
|
||||
}
|
||||
|
||||
private setActiveWindow(windowId: number | undefined) {
|
||||
if (this.firstActiveWindowIdPromise) {
|
||||
this.firstActiveWindowIdPromise = null;
|
||||
this.firstActiveWindowIdPromise.cancel();
|
||||
this.firstActiveWindowIdPromise = undefined;
|
||||
}
|
||||
|
||||
this._activeWindowId = windowId;
|
||||
this.activeWindowId = windowId;
|
||||
}
|
||||
|
||||
getActiveClientId(): Promise<string> {
|
||||
if (this.firstActiveWindowIdPromise) {
|
||||
return this.firstActiveWindowIdPromise;
|
||||
}
|
||||
|
||||
return Promise.resolve(`window:${this._activeWindowId}`);
|
||||
async getActiveClientId(): Promise<string | undefined> {
|
||||
const id = this.firstActiveWindowIdPromise ? (await this.firstActiveWindowIdPromise) : this.activeWindowId;
|
||||
return `window:${id}`;
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IWindowService, IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration, IDevToolsOptions, IOpenSettings, IURIToOpen } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowService, IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration, IDevToolsOptions, IOpenSettings, IURIToOpen, isFolderToOpen, isWorkspaceToOpen } from 'vs/platform/windows/common/windows';
|
||||
import { IRecentlyOpened } from 'vs/platform/history/common/history';
|
||||
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
|
||||
export class WindowService extends Disposable implements IWindowService {
|
||||
@@ -100,7 +99,7 @@ export class WindowService extends Disposable implements IWindowService {
|
||||
|
||||
openWindow(uris: IURIToOpen[], options: IOpenSettings = {}): Promise<void> {
|
||||
if (!!this.configuration.remoteAuthority) {
|
||||
uris.forEach(u => u.label = u.label || this.getRecentLabel(u, !!(options && options.forceOpenWorkspaceAsFile)));
|
||||
uris.forEach(u => u.label = u.label || this.getRecentLabel(u));
|
||||
}
|
||||
return this.windowsService.openWindow(this.windowId, uris, options);
|
||||
}
|
||||
@@ -173,13 +172,13 @@ export class WindowService extends Disposable implements IWindowService {
|
||||
return this.windowsService.resolveProxy(this.windowId, url);
|
||||
}
|
||||
|
||||
private getRecentLabel(u: IURIToOpen, forceOpenWorkspaceAsFile: boolean): string {
|
||||
if (u.typeHint === 'folder') {
|
||||
return this.labelService.getWorkspaceLabel(u.uri, { verbose: true });
|
||||
} else if (!forceOpenWorkspaceAsFile && hasWorkspaceFileExtension(u.uri.path)) {
|
||||
return this.labelService.getWorkspaceLabel({ id: '', configPath: u.uri }, { verbose: true });
|
||||
private getRecentLabel(u: IURIToOpen): string {
|
||||
if (isFolderToOpen(u)) {
|
||||
return this.labelService.getWorkspaceLabel(u.folderUri, { verbose: true });
|
||||
} else if (isWorkspaceToOpen(u)) {
|
||||
return this.labelService.getWorkspaceLabel({ id: '', configPath: u.workspaceUri }, { verbose: true });
|
||||
} else {
|
||||
return this.labelService.getUriLabel(u.uri);
|
||||
return this.labelService.getUriLabel(u.fileUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,10 +98,10 @@ export interface IWindowsMainService {
|
||||
closeWorkspace(win: ICodeWindow): void;
|
||||
open(openConfig: IOpenConfiguration): ICodeWindow[];
|
||||
openExtensionDevelopmentHostWindow(extensionDevelopmentPath: string, openConfig: IOpenConfiguration): void;
|
||||
pickFileFolderAndOpen(options: INativeOpenDialogOptions): void;
|
||||
pickFolderAndOpen(options: INativeOpenDialogOptions): void;
|
||||
pickFileAndOpen(options: INativeOpenDialogOptions): void;
|
||||
pickWorkspaceAndOpen(options: INativeOpenDialogOptions): void;
|
||||
pickFileFolderAndOpen(options: INativeOpenDialogOptions): Promise<void>;
|
||||
pickFolderAndOpen(options: INativeOpenDialogOptions): Promise<void>;
|
||||
pickFileAndOpen(options: INativeOpenDialogOptions): Promise<void>;
|
||||
pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Promise<void>;
|
||||
showMessageBox(options: Electron.MessageBoxOptions, win?: ICodeWindow): Promise<IMessageBoxResult>;
|
||||
showSaveDialog(options: Electron.SaveDialogOptions, win?: ICodeWindow): Promise<string>;
|
||||
showOpenDialog(options: Electron.OpenDialogOptions, win?: ICodeWindow): Promise<string[]>;
|
||||
@@ -133,7 +133,6 @@ export interface IOpenConfiguration {
|
||||
readonly forceEmpty?: boolean;
|
||||
readonly diffMode?: boolean;
|
||||
addMode?: boolean;
|
||||
readonly forceOpenWorkspaceAsFile?: boolean;
|
||||
readonly initialStartup?: boolean;
|
||||
readonly noRecentEntry?: boolean;
|
||||
}
|
||||
|
||||
@@ -290,7 +290,6 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
cli: options.args ? { ...this.environmentService.args, ...options.args } : this.environmentService.args,
|
||||
forceNewWindow: options.forceNewWindow,
|
||||
forceReuseWindow: options.forceReuseWindow,
|
||||
forceOpenWorkspaceAsFile: options.forceOpenWorkspaceAsFile,
|
||||
diffMode: options.diffMode,
|
||||
addMode: options.addMode,
|
||||
noRecentEntry: options.noRecentEntry,
|
||||
@@ -380,6 +379,7 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
version = `${version} (${product.target} setup)`;
|
||||
}
|
||||
|
||||
const isSnap = process.platform === 'linux' && process.env.SNAP && process.env.SNAP_REVISION;
|
||||
// {{SQL CARBON EDIT}}
|
||||
const detail = nls.localize('aboutDetail',
|
||||
"Version: {0}\nCommit: {1}\nDate: {2}\nVS Code {8}\nElectron: {3}\nChrome: {4}\nNode.js: {5}\nV8: {6}\nOS: {7}",
|
||||
@@ -390,7 +390,7 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
process.versions['chrome'],
|
||||
process.versions['node'],
|
||||
process.versions['v8'],
|
||||
`${os.type()} ${os.arch()} ${os.release()}`,
|
||||
`${os.type()} ${os.arch()} ${os.release()}${isSnap ? ' snap' : ''}`,
|
||||
product.vscodeVersion
|
||||
);
|
||||
|
||||
@@ -422,7 +422,7 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
|
||||
// Catch file URLs
|
||||
if (uri.authority === Schemas.file && !!uri.path) {
|
||||
this.openFileForURI({ uri: URI.file(uri.fsPath) }); // using fsPath on a non-file URI...
|
||||
this.openFileForURI({ fileUri: URI.file(uri.fsPath) }); // using fsPath on a non-file URI...
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IServerChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IWindowsService, IURIToOpen, IOpenSettings } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowsService, IURIToOpen, IOpenSettings, isWorkspaceToOpen, isFolderToOpen } from 'vs/platform/windows/common/windows';
|
||||
import { reviveWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IRecent, isRecentFile, isRecentFolder } from 'vs/platform/history/common/history';
|
||||
@@ -89,7 +89,15 @@ export class WindowsChannel implements IServerChannel {
|
||||
case 'openWindow': {
|
||||
const urisToOpen: IURIToOpen[] = arg[1];
|
||||
const options: IOpenSettings = arg[2];
|
||||
urisToOpen.forEach(r => { r.uri = URI.revive(r.uri); return r; });
|
||||
urisToOpen.forEach(r => {
|
||||
if (isWorkspaceToOpen(r)) {
|
||||
r.workspaceUri = URI.revive(r.workspaceUri);
|
||||
} else if (isFolderToOpen(r)) {
|
||||
r.folderUri = URI.revive(r.folderUri);
|
||||
} else {
|
||||
r.fileUri = URI.revive(r.fileUri);
|
||||
}
|
||||
});
|
||||
options.waitMarkerFileURI = options.waitMarkerFileURI && URI.revive(options.waitMarkerFileURI);
|
||||
return this.service.openWindow(arg[0], urisToOpen, options);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user