mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-29 01:25:37 -05:00
Merge from vscode 79a1f5a5ca0c6c53db617aa1fa5a2396d2caebe2
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { DisposableStore, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { CancelablePromise, createCancelablePromise } from 'vs/base/common/async';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
|
||||
export class ActiveWindowManager extends Disposable {
|
||||
|
||||
private readonly disposables = this._register(new DisposableStore());
|
||||
private firstActiveWindowIdPromise: CancelablePromise<number | undefined> | undefined;
|
||||
|
||||
private activeWindowId: number | undefined;
|
||||
|
||||
constructor(@IElectronService electronService: IElectronService) {
|
||||
super();
|
||||
|
||||
// remember last active window id upon events
|
||||
const onActiveWindowChange = Event.latch(Event.any(electronService.onWindowOpen, electronService.onWindowFocus));
|
||||
onActiveWindowChange(this.setActiveWindow, this, this.disposables);
|
||||
|
||||
// resolve current active window
|
||||
this.firstActiveWindowIdPromise = createCancelablePromise(() => electronService.getActiveWindowId());
|
||||
(async () => {
|
||||
try {
|
||||
const windowId = await this.firstActiveWindowIdPromise;
|
||||
this.activeWindowId = (typeof this.activeWindowId === 'number') ? this.activeWindowId : windowId;
|
||||
} finally {
|
||||
this.firstActiveWindowIdPromise = undefined;
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
private setActiveWindow(windowId: number | undefined) {
|
||||
if (this.firstActiveWindowIdPromise) {
|
||||
this.firstActiveWindowIdPromise.cancel();
|
||||
this.firstActiveWindowIdPromise = undefined;
|
||||
}
|
||||
|
||||
this.activeWindowId = windowId;
|
||||
}
|
||||
|
||||
async getActiveClientId(): Promise<string | undefined> {
|
||||
const id = this.firstActiveWindowIdPromise ? (await this.firstActiveWindowIdPromise) : this.activeWindowId;
|
||||
|
||||
return `window:${id}`;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { raceTimeout } from 'vs/base/common/async';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import * as semver from 'semver-umd';
|
||||
@@ -85,7 +86,7 @@ export class Main {
|
||||
} else if (argv['list-extensions']) {
|
||||
await this.listExtensions(!!argv['show-versions'], argv['category']);
|
||||
} else if (argv['install-extension']) {
|
||||
await this.installExtensions(argv['install-extension'], !!argv['force']);
|
||||
await this.installExtensions(argv['install-extension'], !!argv['force'], !!argv['donot-sync']);
|
||||
} else if (argv['uninstall-extension']) {
|
||||
await this.uninstallExtension(argv['uninstall-extension']);
|
||||
} else if (argv['locate-extension']) {
|
||||
@@ -125,7 +126,7 @@ export class Main {
|
||||
extensions.forEach(e => console.log(getId(e.manifest, showVersions)));
|
||||
}
|
||||
|
||||
private async installExtensions(extensions: string[], force: boolean): Promise<void> {
|
||||
private async installExtensions(extensions: string[], force: boolean, donotSync: boolean): Promise<void> {
|
||||
const failed: string[] = [];
|
||||
const installedExtensionsManifests: IExtensionManifest[] = [];
|
||||
if (extensions.length) {
|
||||
@@ -134,7 +135,7 @@ export class Main {
|
||||
|
||||
for (const extension of extensions) {
|
||||
try {
|
||||
const manifest = await this.installExtension(extension, force);
|
||||
const manifest = await this.installExtension(extension, force, donotSync);
|
||||
if (manifest) {
|
||||
installedExtensionsManifests.push(manifest);
|
||||
}
|
||||
@@ -149,7 +150,7 @@ export class Main {
|
||||
return failed.length ? Promise.reject(localize('installation failed', "Failed Installing Extensions: {0}", failed.join(', '))) : Promise.resolve();
|
||||
}
|
||||
|
||||
private async installExtension(extension: string, force: boolean): Promise<IExtensionManifest | null> {
|
||||
private async installExtension(extension: string, force: boolean, donotSync: boolean): Promise<IExtensionManifest | null> {
|
||||
if (/\.vsix$/i.test(extension)) {
|
||||
extension = path.isAbsolute(extension) ? extension : path.join(process.cwd(), extension);
|
||||
|
||||
@@ -157,7 +158,7 @@ export class Main {
|
||||
const valid = await this.validate(manifest, force);
|
||||
|
||||
if (valid) {
|
||||
return this.extensionManagementService.install(URI.file(extension)).then(id => {
|
||||
return this.extensionManagementService.install(URI.file(extension), donotSync).then(id => {
|
||||
console.log(localize('successVsixInstall', "Extension '{0}' was successfully installed.", getBaseLabel(extension)));
|
||||
return manifest;
|
||||
}, error => {
|
||||
@@ -204,7 +205,7 @@ export class Main {
|
||||
}
|
||||
console.log(localize('updateMessage', "Updating the extension '{0}' to the version {1}", id, extension.version));
|
||||
}
|
||||
await this.installFromGallery(id, extension);
|
||||
await this.installFromGallery(id, extension, donotSync);
|
||||
return manifest;
|
||||
}));
|
||||
}
|
||||
@@ -226,11 +227,11 @@ export class Main {
|
||||
return true;
|
||||
}
|
||||
|
||||
private async installFromGallery(id: string, extension: IGalleryExtension): Promise<void> {
|
||||
private async installFromGallery(id: string, extension: IGalleryExtension, donotSync: boolean): Promise<void> {
|
||||
console.log(localize('installing', "Installing extension '{0}' v{1}...", id, extension.version));
|
||||
|
||||
try {
|
||||
await this.extensionManagementService.installFromGallery(extension);
|
||||
await this.extensionManagementService.installFromGallery(extension, donotSync);
|
||||
console.log(localize('successInstall', "Extension '{0}' v{1} was successfully installed.", id, extension.version));
|
||||
} catch (error) {
|
||||
if (isPromiseCanceledError(error)) {
|
||||
@@ -361,8 +362,10 @@ export async function main(argv: ParsedArgs): Promise<void> {
|
||||
|
||||
try {
|
||||
await main.run(argv);
|
||||
|
||||
// Flush the remaining data in AI adapter.
|
||||
await combinedAppender(...appenders).flush();
|
||||
// If it does not complete in 1 second, exit the process.
|
||||
await raceTimeout(combinedAppender(...appenders).flush(), 1000);
|
||||
} finally {
|
||||
disposables.dispose();
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ function doValidatePaths(args: string[], gotoLineMode?: boolean): string[] {
|
||||
const result = args.map(arg => {
|
||||
let pathCandidate = String(arg);
|
||||
|
||||
let parsedPath: IPathWithLineAndColumn | undefined = undefined;
|
||||
let parsedPath: extpath.IPathWithLineAndColumn | undefined = undefined;
|
||||
if (gotoLineMode) {
|
||||
parsedPath = parseLineAndColumnAware(pathCandidate);
|
||||
parsedPath = extpath.parseLineAndColumnAware(pathCandidate);
|
||||
pathCandidate = parsedPath.path;
|
||||
}
|
||||
|
||||
@@ -87,42 +87,7 @@ function preparePath(cwd: string, p: string): string {
|
||||
return p;
|
||||
}
|
||||
|
||||
export interface IPathWithLineAndColumn {
|
||||
path: string;
|
||||
line?: number;
|
||||
column?: number;
|
||||
}
|
||||
|
||||
export function parseLineAndColumnAware(rawPath: string): IPathWithLineAndColumn {
|
||||
const segments = rawPath.split(':'); // C:\file.txt:<line>:<column>
|
||||
|
||||
let path: string | null = null;
|
||||
let line: number | null = null;
|
||||
let column: number | null = null;
|
||||
|
||||
segments.forEach(segment => {
|
||||
const segmentAsNumber = Number(segment);
|
||||
if (!types.isNumber(segmentAsNumber)) {
|
||||
path = !!path ? [path, segment].join(':') : segment; // a colon can well be part of a path (e.g. C:\...)
|
||||
} else if (line === null) {
|
||||
line = segmentAsNumber;
|
||||
} else if (column === null) {
|
||||
column = segmentAsNumber;
|
||||
}
|
||||
});
|
||||
|
||||
if (!path) {
|
||||
throw new Error('Format for `--goto` should be: `FILE:LINE(:COLUMN)`');
|
||||
}
|
||||
|
||||
return {
|
||||
path: path,
|
||||
line: line !== null ? line : undefined,
|
||||
column: column !== null ? column : line !== null ? 1 : undefined // if we have a line, make sure column is also set
|
||||
};
|
||||
}
|
||||
|
||||
function toPath(p: IPathWithLineAndColumn): string {
|
||||
function toPath(p: extpath.IPathWithLineAndColumn): string {
|
||||
const segments = [p.path];
|
||||
|
||||
if (types.isNumber(p.line)) {
|
||||
|
||||
Reference in New Issue
Block a user