mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 709a07d51919d3266ca71699c6ddfb2d3547c0e1 (#6575)
This commit is contained in:
@@ -61,6 +61,7 @@ export interface IBrowserWindowConfiguration {
|
||||
workspaceId: string;
|
||||
remoteAuthority?: string;
|
||||
webviewEndpoint?: string;
|
||||
connectionToken?: string;
|
||||
}
|
||||
|
||||
export class BrowserWorkbenchEnvironmentService implements IEnvironmentService {
|
||||
@@ -81,6 +82,7 @@ export class BrowserWorkbenchEnvironmentService implements IEnvironmentService {
|
||||
this.localeResource = joinPath(this.userRoamingDataHome, 'locale.json');
|
||||
this.backupHome = joinPath(this.userRoamingDataHome, BACKUPS);
|
||||
this.configuration.backupWorkspaceResource = joinPath(this.backupHome, configuration.workspaceId);
|
||||
this.configuration.connectionToken = configuration.connectionToken || this.getConnectionTokenFromLocation();
|
||||
|
||||
this.logsPath = '/web/logs';
|
||||
|
||||
@@ -182,4 +184,21 @@ export class BrowserWorkbenchEnvironmentService implements IEnvironmentService {
|
||||
get webviewCspSource(): string {
|
||||
return this.webviewEndpoint ? this.webviewEndpoint : 'vscode-resource:';
|
||||
}
|
||||
|
||||
private getConnectionTokenFromLocation(): string | undefined {
|
||||
// TODO: Check with @alexd where the token will be: search or hash?
|
||||
let connectionToken: string | undefined = undefined;
|
||||
if (document.location.search) {
|
||||
connectionToken = this.getConnectionToken(document.location.search);
|
||||
}
|
||||
if (!connectionToken && document.location.hash) {
|
||||
connectionToken = this.getConnectionToken(document.location.hash);
|
||||
}
|
||||
return connectionToken;
|
||||
}
|
||||
|
||||
private getConnectionToken(str: string): string | undefined {
|
||||
const m = str.match(/[#&]tkn=([^&]+)/);
|
||||
return m ? m[1] : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +263,11 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
|
||||
return 0;
|
||||
}
|
||||
|
||||
public async setRemoteEnvironment(env: { [key: string]: string | null }): Promise<void> {
|
||||
await this._extensionHostProcessManagers
|
||||
.map(manager => manager.setRemoteEnvironment(env));
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
// --- impl
|
||||
|
||||
@@ -290,6 +290,15 @@ export class ExtensionHostProcessManager extends Disposable {
|
||||
}
|
||||
return proxy.$deltaExtensions(toAdd, toRemove);
|
||||
}
|
||||
|
||||
public async setRemoteEnvironment(env: { [key: string]: string | null }): Promise<void> {
|
||||
const proxy = await this._getExtensionHostProcessProxy();
|
||||
if (!proxy) {
|
||||
return;
|
||||
}
|
||||
|
||||
return proxy.$setRemoteEnvironment(env);
|
||||
}
|
||||
}
|
||||
|
||||
const colorTables = [
|
||||
|
||||
@@ -229,6 +229,12 @@ export interface IExtensionService {
|
||||
*/
|
||||
stopExtensionHost(): void;
|
||||
|
||||
/**
|
||||
* Modify the environment of the remote extension host
|
||||
* @param env New properties for the remote extension host
|
||||
*/
|
||||
setRemoteEnvironment(env: { [key: string]: string | null }): Promise<void>;
|
||||
|
||||
_logOrShowMessage(severity: Severity, msg: string): void;
|
||||
_activateById(extensionId: ExtensionIdentifier, activationEvent: string): Promise<void>;
|
||||
_onWillActivateExtension(extensionId: ExtensionIdentifier): void;
|
||||
@@ -278,6 +284,7 @@ export class NullExtensionService implements IExtensionService {
|
||||
restartExtensionHost(): void { }
|
||||
startExtensionHost(): void { }
|
||||
stopExtensionHost(): void { }
|
||||
async setRemoteEnvironment(_env: { [key: string]: string | null }): Promise<void> { }
|
||||
canAddExtension(): boolean { return false; }
|
||||
canRemoveExtension(): boolean { return false; }
|
||||
_logOrShowMessage(_severity: Severity, _msg: string): void { }
|
||||
|
||||
@@ -71,7 +71,6 @@ export class RemoteExtensionHostClient extends Disposable implements IExtensionH
|
||||
|
||||
public start(): Promise<IMessagePassingProtocol> {
|
||||
const options: IConnectionOptions = {
|
||||
isBuilt: this._environmentService.isBuilt,
|
||||
commit: this._productService.commit,
|
||||
socketFactory: this._socketFactory,
|
||||
addressProvider: {
|
||||
|
||||
@@ -68,7 +68,7 @@ const resourceLabelFormattersExtPoint = ExtensionsRegistry.registerExtensionPoin
|
||||
});
|
||||
|
||||
const sepRegexp = /\//g;
|
||||
const labelMatchingRegexp = /\$\{scheme\}|\$\{authority\}|\$\{path\}/g;
|
||||
const labelMatchingRegexp = /\$\{(scheme|authority|path|(query)\.(.+?))\}/g;
|
||||
|
||||
function hasDriveLetter(path: string): boolean {
|
||||
return !!(isWindows && path && path[2] === ':');
|
||||
@@ -222,12 +222,23 @@ export class LabelService implements ILabelService {
|
||||
}
|
||||
|
||||
private formatUri(resource: URI, formatting: ResourceLabelFormatting, forceNoTildify?: boolean): string {
|
||||
let label = formatting.label.replace(labelMatchingRegexp, match => {
|
||||
switch (match) {
|
||||
case '${scheme}': return resource.scheme;
|
||||
case '${authority}': return resource.authority;
|
||||
case '${path}': return resource.path;
|
||||
default: return '';
|
||||
let label = formatting.label.replace(labelMatchingRegexp, (match, token, qsToken, qsValue) => {
|
||||
switch (token) {
|
||||
case 'scheme': return resource.scheme;
|
||||
case 'authority': return resource.authority;
|
||||
case 'path': return resource.path;
|
||||
default: {
|
||||
if (qsToken === 'query') {
|
||||
const { query } = resource;
|
||||
if (query && query[0] === '{' && query[query.length - 1] === '}') {
|
||||
try {
|
||||
return JSON.parse(query)[qsValue] || '';
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -265,4 +276,4 @@ export class LabelService implements ILabelService {
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(ILabelService, LabelService, true);
|
||||
registerSingleton(ILabelService, LabelService, true);
|
||||
|
||||
@@ -97,4 +97,64 @@ suite('URI Label', () => {
|
||||
const uri1 = URI.parse('vscode://microsoft.com/1/2/3/4/5');
|
||||
assert.equal(labelService.getUriLabel(uri1, { relative: false }), 'second');
|
||||
});
|
||||
|
||||
test('custom query', function () {
|
||||
labelService.registerFormatter({
|
||||
scheme: 'vscode',
|
||||
formatting: {
|
||||
label: 'LABEL${query.prefix}: ${query.path}/END',
|
||||
separator: '/',
|
||||
tildify: true,
|
||||
normalizeDriveLetter: true
|
||||
}
|
||||
});
|
||||
|
||||
const uri1 = URI.parse(`vscode://microsoft.com/1/2/3/4/5?${encodeURIComponent(JSON.stringify({ prefix: 'prefix', path: 'path' }))}`);
|
||||
assert.equal(labelService.getUriLabel(uri1, { relative: false }), 'LABELprefix: path/END');
|
||||
});
|
||||
|
||||
test('custom query without value', function () {
|
||||
labelService.registerFormatter({
|
||||
scheme: 'vscode',
|
||||
formatting: {
|
||||
label: 'LABEL${query.prefix}: ${query.path}/END',
|
||||
separator: '/',
|
||||
tildify: true,
|
||||
normalizeDriveLetter: true
|
||||
}
|
||||
});
|
||||
|
||||
const uri1 = URI.parse(`vscode://microsoft.com/1/2/3/4/5?${encodeURIComponent(JSON.stringify({ path: 'path' }))}`);
|
||||
assert.equal(labelService.getUriLabel(uri1, { relative: false }), 'LABEL: path/END');
|
||||
});
|
||||
|
||||
test('custom query without query json', function () {
|
||||
labelService.registerFormatter({
|
||||
scheme: 'vscode',
|
||||
formatting: {
|
||||
label: 'LABEL${query.prefix}: ${query.path}/END',
|
||||
separator: '/',
|
||||
tildify: true,
|
||||
normalizeDriveLetter: true
|
||||
}
|
||||
});
|
||||
|
||||
const uri1 = URI.parse('vscode://microsoft.com/1/2/3/4/5?path=foo');
|
||||
assert.equal(labelService.getUriLabel(uri1, { relative: false }), 'LABEL: /END');
|
||||
});
|
||||
|
||||
test('custom query without query', function () {
|
||||
labelService.registerFormatter({
|
||||
scheme: 'vscode',
|
||||
formatting: {
|
||||
label: 'LABEL${query.prefix}: ${query.path}/END',
|
||||
separator: '/',
|
||||
tildify: true,
|
||||
normalizeDriveLetter: true
|
||||
}
|
||||
});
|
||||
|
||||
const uri1 = URI.parse('vscode://microsoft.com/1/2/3/4/5');
|
||||
assert.equal(labelService.getUriLabel(uri1, { relative: false }), 'LABEL: /END');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ export class RemoteAgentService extends AbstractRemoteAgentService implements IR
|
||||
super(environmentService);
|
||||
|
||||
this.socketFactory = new BrowserSocketFactory(webSocketFactory);
|
||||
this._connection = this._register(new RemoteAgentConnection(environmentService.configuration.remoteAuthority!, productService.commit, this.socketFactory, environmentService, remoteAuthorityResolverService, signService));
|
||||
this._connection = this._register(new RemoteAgentConnection(environmentService.configuration.remoteAuthority!, productService.commit, this.socketFactory, remoteAuthorityResolverService, signService));
|
||||
}
|
||||
|
||||
getConnection(): IRemoteAgentConnection | null {
|
||||
|
||||
@@ -84,7 +84,6 @@ export class RemoteAgentConnection extends Disposable implements IRemoteAgentCon
|
||||
remoteAuthority: string,
|
||||
private readonly _commit: string | undefined,
|
||||
private readonly _socketFactory: ISocketFactory,
|
||||
private readonly _environmentService: IEnvironmentService,
|
||||
private readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService,
|
||||
private readonly _signService: ISignService
|
||||
) {
|
||||
@@ -111,7 +110,6 @@ export class RemoteAgentConnection extends Disposable implements IRemoteAgentCon
|
||||
private async _createConnection(): Promise<Client<RemoteAgentConnectionContext>> {
|
||||
let firstCall = true;
|
||||
const options: IConnectionOptions = {
|
||||
isBuilt: this._environmentService.isBuilt,
|
||||
commit: this._commit,
|
||||
socketFactory: this._socketFactory,
|
||||
addressProvider: {
|
||||
|
||||
@@ -27,7 +27,7 @@ export class RemoteAgentService extends AbstractRemoteAgentService implements IR
|
||||
super(environmentService);
|
||||
this.socketFactory = nodeSocketFactory;
|
||||
if (remoteAuthority) {
|
||||
this._connection = this._register(new RemoteAgentConnection(remoteAuthority, product.commit, nodeSocketFactory, environmentService, remoteAuthorityResolverService, signService));
|
||||
this._connection = this._register(new RemoteAgentConnection(remoteAuthority, product.commit, nodeSocketFactory, remoteAuthorityResolverService, signService));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,6 @@ export class TunnelService implements ITunnelService {
|
||||
}
|
||||
|
||||
const options: IConnectionOptions = {
|
||||
isBuilt: this.environmentService.isBuilt,
|
||||
commit: product.commit,
|
||||
socketFactory: nodeSocketFactory,
|
||||
addressProvider: {
|
||||
|
||||
Reference in New Issue
Block a user