mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Vscode merge (#4582)
* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd * fix issues with merges * bump node version in azpipe * replace license headers * remove duplicate launch task * fix build errors * fix build errors * fix tslint issues * working through package and linux build issues * more work * wip * fix packaged builds * working through linux build errors * wip * wip * wip * fix mac and linux file limits * iterate linux pipeline * disable editor typing * revert series to parallel * remove optimize vscode from linux * fix linting issues * revert testing change * add work round for new node * readd packaging for extensions * fix issue with angular not resolving decorator dependencies
This commit is contained in:
@@ -11,24 +11,20 @@ import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry, IWo
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IWorkspaceContextService, IWorkspace } from 'vs/platform/workspace/common/workspace';
|
||||
import { isEqual, basenameOrAuthority, basename as resourceBasename } from 'vs/base/common/resources';
|
||||
import { isLinux, isWindows } from 'vs/base/common/platform';
|
||||
import { isEqual, basenameOrAuthority, isEqualOrParent, basename, joinPath, dirname } from 'vs/base/common/resources';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { tildify, getPathLabel } from 'vs/base/common/labels';
|
||||
import { ltrim } from 'vs/base/common/strings';
|
||||
import { ltrim, endsWith } from 'vs/base/common/strings';
|
||||
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, WORKSPACE_EXTENSION, toWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { isParent } from 'vs/platform/files/common/files';
|
||||
import { basename, dirname, join } from 'vs/base/common/paths';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IWindowService } from 'vs/platform/windows/common/windows';
|
||||
import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { ILabelService, ResourceLabelFormatter, ResourceLabelFormatting } from 'vs/platform/label/common/label';
|
||||
import { ExtensionsRegistry } from 'vs/workbench/services/extensions/common/extensionsRegistry';
|
||||
import { match } from 'vs/base/common/glob';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
|
||||
const resourceLabelFormattersExtPoint = ExtensionsRegistry.registerExtensionPoint<ResourceLabelFormatter[]>({
|
||||
extensionPoint: 'resourceLabelFormatters',
|
||||
isDynamic: true,
|
||||
jsonSchema: {
|
||||
description: localize('vscode.extension.contributes.resourceLabelFormatters', 'Contributes resource label formatting rules.'),
|
||||
type: 'array',
|
||||
@@ -103,7 +99,6 @@ export class LabelService implements ILabelService {
|
||||
constructor(
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
|
||||
@IWindowService private readonly windowService: IWindowService
|
||||
) { }
|
||||
|
||||
get onDidChangeFormatters(): Event<void> {
|
||||
@@ -123,7 +118,7 @@ export class LabelService implements ILabelService {
|
||||
return;
|
||||
}
|
||||
|
||||
if (match(formatter.authority, resource.authority) && (!bestResult || !bestResult.authority || formatter.authority.length > bestResult.authority.length)) {
|
||||
if (match(formatter.authority, resource.authority) && (!bestResult || !bestResult.authority || formatter.authority.length > bestResult.authority.length || ((formatter.authority.length === bestResult.authority.length) && formatter.priority))) {
|
||||
bestResult = formatter;
|
||||
}
|
||||
}
|
||||
@@ -132,34 +127,36 @@ export class LabelService implements ILabelService {
|
||||
return bestResult ? bestResult.formatting : undefined;
|
||||
}
|
||||
|
||||
getUriLabel(resource: URI, options: { relative?: boolean, noPrefix?: boolean } = {}): string {
|
||||
getUriLabel(resource: URI, options: { relative?: boolean, noPrefix?: boolean, endWithSeparator?: boolean } = {}): string {
|
||||
const formatting = this.findFormatting(resource);
|
||||
if (!formatting) {
|
||||
return getPathLabel(resource.path, this.environmentService, options.relative ? this.contextService : undefined);
|
||||
}
|
||||
|
||||
if (options.relative) {
|
||||
const baseResource = this.contextService && this.contextService.getWorkspaceFolder(resource);
|
||||
if (baseResource) {
|
||||
let relativeLabel: string;
|
||||
if (isEqual(baseResource.uri, resource, !isLinux)) {
|
||||
relativeLabel = ''; // no label if resources are identical
|
||||
} else {
|
||||
const baseResourceLabel = this.formatUri(baseResource.uri, formatting, options.noPrefix);
|
||||
relativeLabel = ltrim(this.formatUri(resource, formatting, options.noPrefix).substring(baseResourceLabel.length), formatting.separator);
|
||||
}
|
||||
let label: string | undefined;
|
||||
const baseResource = this.contextService && this.contextService.getWorkspaceFolder(resource);
|
||||
|
||||
const hasMultipleRoots = this.contextService.getWorkspace().folders.length > 1;
|
||||
if (hasMultipleRoots && !options.noPrefix) {
|
||||
const rootName = (baseResource && baseResource.name) ? baseResource.name : basenameOrAuthority(baseResource.uri);
|
||||
relativeLabel = relativeLabel ? (rootName + ' • ' + relativeLabel) : rootName; // always show root basename if there are multiple
|
||||
}
|
||||
|
||||
return relativeLabel;
|
||||
if (options.relative && baseResource) {
|
||||
let relativeLabel: string;
|
||||
if (isEqual(baseResource.uri, resource)) {
|
||||
relativeLabel = ''; // no label if resources are identical
|
||||
} else {
|
||||
const baseResourceLabel = this.formatUri(baseResource.uri, formatting, options.noPrefix);
|
||||
relativeLabel = ltrim(this.formatUri(resource, formatting, options.noPrefix).substring(baseResourceLabel.length), formatting.separator);
|
||||
}
|
||||
|
||||
const hasMultipleRoots = this.contextService.getWorkspace().folders.length > 1;
|
||||
if (hasMultipleRoots && !options.noPrefix) {
|
||||
const rootName = (baseResource && baseResource.name) ? baseResource.name : basenameOrAuthority(baseResource.uri);
|
||||
relativeLabel = relativeLabel ? (rootName + ' • ' + relativeLabel) : rootName; // always show root basename if there are multiple
|
||||
}
|
||||
|
||||
label = relativeLabel;
|
||||
} else {
|
||||
label = this.formatUri(resource, formatting, options.noPrefix);
|
||||
}
|
||||
|
||||
return this.formatUri(resource, formatting, options.noPrefix);
|
||||
return options.endWithSeparator ? this.appendSeparatorIfMissing(label, formatting) : label;
|
||||
}
|
||||
|
||||
getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | IWorkspace), options?: { verbose: boolean }): string {
|
||||
@@ -175,42 +172,35 @@ export class LabelService implements ILabelService {
|
||||
// Workspace: Single Folder
|
||||
if (isSingleFolderWorkspaceIdentifier(workspace)) {
|
||||
// Folder on disk
|
||||
const label = options && options.verbose ? this.getUriLabel(workspace) : resourceBasename(workspace) || '/';
|
||||
if (workspace.scheme === Schemas.file) {
|
||||
return label;
|
||||
}
|
||||
|
||||
const formatting = this.findFormatting(workspace);
|
||||
const suffix = formatting && (typeof formatting.workspaceSuffix === 'string') ? formatting.workspaceSuffix : workspace.scheme;
|
||||
return suffix ? `${label} (${suffix})` : label;
|
||||
const label = options && options.verbose ? this.getUriLabel(workspace) : basename(workspace) || '/';
|
||||
return this.appendWorkspaceSuffix(label, workspace);
|
||||
}
|
||||
|
||||
// Workspace: Untitled
|
||||
if (isParent(workspace.configPath, this.environmentService.workspacesHome, !isLinux /* ignore case */)) {
|
||||
if (isEqualOrParent(workspace.configPath, this.environmentService.untitledWorkspacesHome)) {
|
||||
return localize('untitledWorkspace', "Untitled (Workspace)");
|
||||
}
|
||||
|
||||
// Workspace: Saved
|
||||
const filename = basename(workspace.configPath);
|
||||
const workspaceName = filename.substr(0, filename.length - WORKSPACE_EXTENSION.length - 1);
|
||||
let label;
|
||||
if (options && options.verbose) {
|
||||
return localize('workspaceNameVerbose', "{0} (Workspace)", this.getUriLabel(URI.file(join(dirname(workspace.configPath), workspaceName))));
|
||||
label = localize('workspaceNameVerbose', "{0} (Workspace)", this.getUriLabel(joinPath(dirname(workspace.configPath), workspaceName)));
|
||||
} else {
|
||||
label = localize('workspaceName', "{0} (Workspace)", workspaceName);
|
||||
}
|
||||
|
||||
return localize('workspaceName', "{0} (Workspace)", workspaceName);
|
||||
return this.appendWorkspaceSuffix(label, workspace.configPath);
|
||||
}
|
||||
|
||||
getHostLabel(): string {
|
||||
if (this.windowService) {
|
||||
const authority = this.windowService.getConfiguration().remoteAuthority;
|
||||
if (authority) {
|
||||
const formatter = this.findFormatting(URI.from({ scheme: REMOTE_HOST_SCHEME, authority }));
|
||||
if (formatter && formatter.workspaceSuffix) {
|
||||
return formatter.workspaceSuffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
return '';
|
||||
getSeparator(scheme: string, authority?: string): '/' | '\\' {
|
||||
const formatter = this.findFormatting(URI.from({ scheme, authority }));
|
||||
return formatter && formatter.separator || '/';
|
||||
}
|
||||
|
||||
getHostLabel(scheme: string, authority?: string): string {
|
||||
const formatter = this.findFormatting(URI.from({ scheme, authority }));
|
||||
return formatter && formatter.workspaceSuffix || '';
|
||||
}
|
||||
|
||||
registerFormatter(formatter: ResourceLabelFormatter): IDisposable {
|
||||
@@ -249,4 +239,24 @@ export class LabelService implements ILabelService {
|
||||
|
||||
return label.replace(sepRegexp, formatting.separator);
|
||||
}
|
||||
|
||||
private appendSeparatorIfMissing(label: string, formatting: ResourceLabelFormatting): string {
|
||||
let appendedLabel = label;
|
||||
if (!endsWith(label, formatting.separator)) {
|
||||
appendedLabel += formatting.separator;
|
||||
}
|
||||
return appendedLabel;
|
||||
}
|
||||
|
||||
private appendWorkspaceSuffix(label: string, uri: URI): string {
|
||||
if (uri.scheme === Schemas.file) {
|
||||
return label;
|
||||
}
|
||||
|
||||
const formatting = this.findFormatting(uri);
|
||||
const suffix = formatting && (typeof formatting.workspaceSuffix === 'string') ? formatting.workspaceSuffix : uri.scheme;
|
||||
return suffix ? `${label} [${suffix}]` : label;
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(ILabelService, LabelService, true);
|
||||
@@ -4,10 +4,10 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { TestEnvironmentService, TestContextService, TestWindowService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { TestEnvironmentService, TestContextService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { nativeSep } from 'vs/base/common/paths';
|
||||
import { sep } from 'vs/base/common/path';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { LabelService } from 'vs/workbench/services/label/common/labelService';
|
||||
|
||||
@@ -16,7 +16,7 @@ suite('URI Label', () => {
|
||||
let labelService: LabelService;
|
||||
|
||||
setup(() => {
|
||||
labelService = new LabelService(TestEnvironmentService, new TestContextService(), new TestWindowService());
|
||||
labelService = new LabelService(TestEnvironmentService, new TestContextService());
|
||||
});
|
||||
|
||||
test('file scheme', function () {
|
||||
@@ -24,7 +24,7 @@ suite('URI Label', () => {
|
||||
scheme: 'file',
|
||||
formatting: {
|
||||
label: '${path}',
|
||||
separator: nativeSep,
|
||||
separator: sep,
|
||||
tildify: !isWindows,
|
||||
normalizeDriveLetter: isWindows
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user