提交 9a7535c8 编写于 作者: I isidor

getPathLabel: make only rootProvider optional

上级 2b1557dc
......@@ -184,6 +184,6 @@ export class FileLabel extends IconLabel {
public setFile(file: uri, provider: IWorkspaceFolderProvider, userHome: IUserHomeProvider): void {
const parent = paths.dirname(file.fsPath);
this.setValue(getBaseLabel(file), parent && parent !== '.' ? getPathLabel(parent, provider, userHome) : '', { title: file.fsPath });
this.setValue(getBaseLabel(file), parent && parent !== '.' ? getPathLabel(parent, userHome, provider) : '', { title: file.fsPath });
}
}
......@@ -21,7 +21,7 @@ export interface IUserHomeProvider {
userHome: string;
}
export function getPathLabel(resource: URI | string, rootProvider?: IWorkspaceFolderProvider, userHomeProvider?: IUserHomeProvider): string {
export function getPathLabel(resource: URI | string, userHomeProvider: IUserHomeProvider, rootProvider?: IWorkspaceFolderProvider): string {
if (!resource) {
return null;
}
......
......@@ -490,7 +490,7 @@ export class CodeMenu {
let label: string;
let path: string;
if (isSingleFolderWorkspaceIdentifier(workspace) || typeof workspace === 'string') {
label = unmnemonicLabel(getPathLabel(workspace, null, this.environmentService));
label = unmnemonicLabel(getPathLabel(workspace, this.environmentService));
path = workspace;
} else {
label = getWorkspaceLabel(workspace, this.environmentService, { verbose: true });
......
......@@ -114,7 +114,7 @@ class MessageWidget {
let relatedResource = document.createElement('span');
dom.addClass(relatedResource, 'filename');
relatedResource.innerHTML = `${getBaseLabel(related.resource)}(${related.startLineNumber}, ${related.startColumn}): `;
relatedResource.title = getPathLabel(related.resource);
relatedResource.title = getPathLabel(related.resource, undefined);
this._relatedDiagnostics.set(relatedResource, related);
let relatedMessage = document.createElement('span');
......
......@@ -780,7 +780,7 @@ export class ReferenceWidget extends PeekViewWidget {
// Update widget header
if (reference.uri.scheme !== Schemas.inMemory) {
this.setTitle(reference.name, getPathLabel(reference.directory, this._contextService, this._environmentService));
this.setTitle(reference.name, getPathLabel(reference.directory, this._environmentService, this._contextService, ));
} else {
this.setTitle(nls.localize('peekView.alternateTitle', "References"));
}
......
......@@ -254,7 +254,7 @@ export class HistoryMainService implements IHistoryMainService {
name: nls.localize('recentFolders', "Recent Workspaces"),
items: this.getRecentlyOpened().workspaces.slice(0, 7 /* limit number of entries here */).map(workspace => {
const title = isSingleFolderWorkspaceIdentifier(workspace) ? getBaseLabel(workspace) : getWorkspaceLabel(workspace, this.environmentService);
const description = isSingleFolderWorkspaceIdentifier(workspace) ? nls.localize('folderDesc', "{0} {1}", getBaseLabel(workspace), getPathLabel(path.dirname(workspace))) : nls.localize('codeWorkspace', "Code Workspace");
const description = isSingleFolderWorkspaceIdentifier(workspace) ? nls.localize('folderDesc', "{0} {1}", getBaseLabel(workspace), getPathLabel(path.dirname(workspace), this.environmentService)) : nls.localize('codeWorkspace', "Code Workspace");
return <Electron.JumpListItem>{
type: 'task',
......@@ -280,4 +280,4 @@ export class HistoryMainService implements IHistoryMainService {
this.logService.warn('#setJumpList', error); // since setJumpList is relatively new API, make sure to guard for errors
}
}
}
\ No newline at end of file
}
......@@ -125,7 +125,7 @@ export function getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFold
const filename = basename(workspace.configPath);
const workspaceName = filename.substr(0, filename.length - WORKSPACE_EXTENSION.length - 1);
if (options && options.verbose) {
return localize('workspaceNameVerbose', "{0} (Workspace)", getPathLabel(join(dirname(workspace.configPath), workspaceName), null, environmentService));
return localize('workspaceNameVerbose', "{0} (Workspace)", getPathLabel(join(dirname(workspace.configPath), workspaceName), environmentService));
}
return localize('workspaceName', "{0} (Workspace)", workspaceName);
......
......@@ -170,7 +170,7 @@ CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, function (acc
const folderPicks = folders.map(folder => {
return {
label: folder.name,
description: getPathLabel(resources.dirname(folder.uri), void 0, environmentService),
description: getPathLabel(resources.dirname(folder.uri), environmentService),
folder,
resource: folder.uri,
fileKind: FileKind.ROOT_FOLDER
......
......@@ -370,7 +370,7 @@ export function fillResourceDataTransfers(accessor: ServicesAccessor, resources:
// Text: allows to paste into text-capable areas
const lineDelimiter = isWindows ? '\r\n' : '\n';
event.dataTransfer.setData(DataTransfers.TEXT, sources.map(source => source.resource.scheme === Schemas.file ? getPathLabel(source.resource) : source.resource.toString()).join(lineDelimiter));
event.dataTransfer.setData(DataTransfers.TEXT, sources.map(source => source.resource.scheme === Schemas.file ? getPathLabel(source.resource, undefined) : source.resource.toString()).join(lineDelimiter));
// Download URL: enables support to drag a tab as file to desktop (only single file supported)
if (firstSource.resource.scheme === Schemas.file) {
......@@ -517,4 +517,4 @@ export class DragAndDropObserver extends Disposable {
this.callbacks.onDrop(e);
}));
}
}
\ No newline at end of file
}
......@@ -196,7 +196,7 @@ export class ResourceLabel extends IconLabel {
iconLabelOptions.title = this.options.title;
} else if (resource && resource.scheme !== Schemas.data /* do not accidentally inline Data URIs */) {
if (!this.computedPathLabel) {
this.computedPathLabel = getPathLabel(resource, void 0, this.environmentService);
this.computedPathLabel = getPathLabel(resource, this.environmentService);
}
iconLabelOptions.title = this.computedPathLabel;
......@@ -314,7 +314,7 @@ export class FileLabel extends ResourceLabel {
rootProvider = this.contextService;
}
description = getPathLabel(resources.dirname(resource), rootProvider, this.environmentService);
description = getPathLabel(resources.dirname(resource), this.environmentService, rootProvider);
}
this.setLabel({ resource, name, description }, options);
......
......@@ -1190,7 +1190,7 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry {
const resourceInput = input as IResourceInput;
this.resource = resourceInput.resource;
this.label = labels.getBaseLabel(resourceInput.resource);
this.description = labels.getPathLabel(resources.dirname(this.resource), contextService, environmentService);
this.description = labels.getPathLabel(resources.dirname(this.resource), environmentService, contextService);
this.dirty = this.resource && this.textFileService.isDirty(this.resource);
if (this.dirty && this.textFileService.getAutoSaveMode() === AutoSaveMode.AFTER_SHORT_DELAY) {
......
......@@ -203,9 +203,9 @@ export class TitlebarPart extends Part implements ITitleService {
const activeEditorMedium = editor ? editor.getTitle(Verbosity.MEDIUM) : activeEditorShort;
const activeEditorLong = editor ? editor.getTitle(Verbosity.LONG) : activeEditorMedium;
const rootName = workspace.name;
const rootPath = root ? labels.getPathLabel(root, void 0, this.environmentService) : '';
const rootPath = root ? labels.getPathLabel(root, this.environmentService) : '';
const folderName = folder ? folder.name : '';
const folderPath = folder ? labels.getPathLabel(folder.uri, void 0, this.environmentService) : '';
const folderPath = folder ? labels.getPathLabel(folder.uri, this.environmentService) : '';
const dirty = editor && editor.isDirty() ? TitlebarPart.TITLE_DIRTY : '';
const appName = this.environmentService.appNameLong;
const separator = TitlebarPart.TITLE_SEPARATOR;
......@@ -361,4 +361,4 @@ class ShowItemInFolderAction extends Action {
public run(): TPromise<void> {
return this.windowsService.showItemInFolder(this.path);
}
}
\ No newline at end of file
}
......@@ -94,17 +94,17 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
@memoize
private get shortDescription(): string {
return paths.basename(labels.getPathLabel(resources.dirname(this.resource), void 0, this.environmentService));
return paths.basename(labels.getPathLabel(resources.dirname(this.resource), this.environmentService));
}
@memoize
private get mediumDescription(): string {
return labels.getPathLabel(resources.dirname(this.resource), this.contextService, this.environmentService);
return labels.getPathLabel(resources.dirname(this.resource), this.environmentService, this.contextService);
}
@memoize
private get longDescription(): string {
return labels.getPathLabel(resources.dirname(this.resource), void 0, this.environmentService);
return labels.getPathLabel(resources.dirname(this.resource), this.environmentService);
}
public getDescription(verbosity: Verbosity = Verbosity.MEDIUM): string {
......@@ -136,12 +136,12 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
@memoize
private get mediumTitle(): string {
return labels.getPathLabel(this.resource, this.contextService, this.environmentService);
return labels.getPathLabel(this.resource, this.environmentService, this.contextService);
}
@memoize
private get longTitle(): string {
return labels.getPathLabel(this.resource, void 0, this.environmentService);
return labels.getPathLabel(this.resource, this.environmentService);
}
public getTitle(verbosity: Verbosity): string {
......@@ -295,4 +295,4 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
super.dispose();
}
}
\ No newline at end of file
}
......@@ -730,11 +730,11 @@ export abstract class BaseOpenRecentAction extends Action {
if (isSingleFolderWorkspaceIdentifier(workspace)) {
path = workspace;
label = getBaseLabel(path);
description = getPathLabel(paths.dirname(path), null, environmentService);
description = getPathLabel(paths.dirname(path), environmentService);
} else {
path = workspace.configPath;
label = getWorkspaceLabel(workspace, environmentService);
description = getPathLabel(paths.dirname(workspace.configPath), null, environmentService);
description = getPathLabel(paths.dirname(workspace.configPath), environmentService);
}
return {
......
......@@ -320,12 +320,12 @@ class BreakpointsRenderer implements IRenderer<IBreakpoint, IBreakpointTemplateD
data.context = breakpoint;
dom.toggleClass(data.breakpoint, 'disabled', !this.debugService.getModel().areBreakpointsActivated());
data.name.textContent = basename(getPathLabel(breakpoint.uri, this.contextService));
data.name.textContent = basename(getPathLabel(breakpoint.uri, this.environmentService, this.contextService));
data.lineNumber.textContent = breakpoint.lineNumber.toString();
if (breakpoint.column) {
data.lineNumber.textContent += `:${breakpoint.column}`;
}
data.filePath.textContent = getPathLabel(resources.dirname(breakpoint.uri), this.contextService, this.environmentService);
data.filePath.textContent = getPathLabel(resources.dirname(breakpoint.uri), this.environmentService, this.contextService);
data.checkbox.checked = breakpoint.enabled;
const { message, className } = getBreakpointMessageAndClassName(this.debugService, this.textFileService, breakpoint);
......
......@@ -138,17 +138,17 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
@memoize
private get shortDescription(): string {
return paths.basename(labels.getPathLabel(resources.dirname(this.resource), void 0, this.environmentService));
return paths.basename(labels.getPathLabel(resources.dirname(this.resource), this.environmentService));
}
@memoize
private get mediumDescription(): string {
return labels.getPathLabel(resources.dirname(this.resource), this.contextService, this.environmentService);
return labels.getPathLabel(resources.dirname(this.resource), this.environmentService, this.contextService);
}
@memoize
private get longDescription(): string {
return labels.getPathLabel(resources.dirname(this.resource), void 0, this.environmentService);
return labels.getPathLabel(resources.dirname(this.resource), this.environmentService);
}
public getDescription(verbosity: Verbosity = Verbosity.MEDIUM): string {
......@@ -176,12 +176,12 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
@memoize
private get mediumTitle(): string {
return labels.getPathLabel(this.resource, this.contextService, this.environmentService);
return labels.getPathLabel(this.resource, this.environmentService, this.contextService);
}
@memoize
private get longTitle(): string {
return labels.getPathLabel(this.resource, void 0, this.environmentService);
return labels.getPathLabel(this.resource, this.environmentService);
}
public getTitle(verbosity: Verbosity): string {
......
......@@ -14,7 +14,6 @@ import { IFileStat } from 'vs/platform/files/common/files';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { toResource, IEditorIdentifier, IEditorInput } from 'vs/workbench/common/editor';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { getPathLabel } from 'vs/base/common/labels';
import { Schemas } from 'vs/base/common/network';
import { startsWith, startsWithIgnoreCase, rtrim } from 'vs/base/common/strings';
import { IEditorGroup } from 'vs/workbench/services/group/common/editorGroupsService';
......@@ -78,7 +77,7 @@ export class ExplorerItem {
public isDirectoryResolved: boolean;
constructor(resource: URI, public root: ExplorerItem, isSymbolicLink?: boolean, isDirectory?: boolean, name: string = getPathLabel(resource), mtime?: number, etag?: string) {
constructor(resource: URI, public root: ExplorerItem, isSymbolicLink?: boolean, isDirectory?: boolean, name: string = resources.basenameOrAuthority(resource), mtime?: number, etag?: string) {
this.resource = resource;
this._name = name;
this.isDirectory = !!isDirectory;
......
......@@ -53,7 +53,7 @@ export class ConfigureLocaleAction extends Action {
}
});
}, (error) => {
throw new Error(localize('fail.createSettings', "Unable to create '{0}' ({1}).", getPathLabel(file, this.contextService), error));
throw new Error(localize('fail.createSettings', "Unable to create '{0}' ({1}).", getPathLabel(file, this.environmentService, this.contextService), error));
});
}
}
\ No newline at end of file
}
......@@ -164,7 +164,7 @@ export class OpenFileHandler extends QuickOpenHandler {
const fileMatch = complete.results[i];
const label = paths.basename(fileMatch.resource.fsPath);
const description = labels.getPathLabel(resources.dirname(fileMatch.resource), this.contextService, this.environmentService);
const description = labels.getPathLabel(resources.dirname(fileMatch.resource), this.environmentService, this.contextService);
results.push(this.instantiationService.createInstance(FileEntry, fileMatch.resource, label, description, iconClass));
}
......
......@@ -56,7 +56,7 @@ class SymbolEntry extends EditorQuickOpenEntry {
if (containerName) {
return `${containerName}${basename(this._bearing.location.uri.fsPath)}`;
} else {
return labels.getPathLabel(this._bearing.location.uri, this._contextService, this._environmentService);
return labels.getPathLabel(this._bearing.location.uri, this._environmentService, this._contextService);
}
}
return containerName;
......
......@@ -28,6 +28,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions';
import { WorkbenchTreeController, WorkbenchTree } from 'vs/platform/list/browser/listService';
import { fillInContextMenuActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
export class SearchDataSource implements IDataSource {
......@@ -318,7 +319,10 @@ export class SearchRenderer extends Disposable implements IRenderer {
export class SearchAccessibilityProvider implements IAccessibilityProvider {
constructor(@IWorkspaceContextService private contextService: IWorkspaceContextService) {
constructor(
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IEnvironmentService private environmentService: IEnvironmentService
) {
}
public getAriaLabel(tree: ITree, element: FileMatchOrMatch): string {
......@@ -327,7 +331,7 @@ export class SearchAccessibilityProvider implements IAccessibilityProvider {
}
if (element instanceof FileMatch) {
const path = getPathLabel(element.resource(), this.contextService) || element.resource().fsPath;
const path = getPathLabel(element.resource(), this.environmentService, this.contextService) || element.resource().fsPath;
return nls.localize('fileMatchAriaLabel', "{0} matches in file {1} of folder {2}, Search result", element.count(), element.name(), paths.dirname(path));
}
......
......@@ -23,6 +23,7 @@ import { FileChangeType, IFileService } from 'vs/platform/files/common/files';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IProgress, IProgressRunner, emptyProgressRunner } from 'vs/platform/progress/common/progress';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
abstract class Recording {
......@@ -266,7 +267,8 @@ export class BulkEdit {
editor: ICodeEditor,
progress: IProgressRunner,
@ITextModelService private readonly _textModelService: ITextModelService,
@IFileService private readonly _fileService: IFileService
@IFileService private readonly _fileService: IFileService,
@IEnvironmentService private readonly _environmentService: IEnvironmentService
) {
this._editor = editor;
this._progress = progress || emptyProgressRunner;
......@@ -359,7 +361,7 @@ export class BulkEdit {
const conflicts = edits
.filter(edit => recording.hasChanged(edit.resource))
.map(edit => getPathLabel(edit.resource));
.map(edit => getPathLabel(edit.resource, this._environmentService));
recording.stop();
......@@ -382,7 +384,8 @@ export class BulkEditService implements IBulkEditService {
@IModelService private readonly _modelService: IModelService,
@IEditorService private readonly _editorService: IEditorService,
@ITextModelService private readonly _textModelService: ITextModelService,
@IFileService private readonly _fileService: IFileService
@IFileService private readonly _fileService: IFileService,
@IEnvironmentService private readonly _environmentService: IEnvironmentService
) {
}
......@@ -413,7 +416,7 @@ export class BulkEditService implements IBulkEditService {
}
}
const bulkEdit = new BulkEdit(options.editor, options.progress, this._textModelService, this._fileService);
const bulkEdit = new BulkEdit(options.editor, options.progress, this._textModelService, this._fileService, this._environmentService);
bulkEdit.add(edits);
return bulkEdit.perform().then(selection => {
return {
......
......@@ -571,7 +571,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
}
// Otherwise: for diff labels prefer to see the path as part of the label
return getPathLabel(res.fsPath, context, environment);
return getPathLabel(res.fsPath, environment, context);
}
//#endregion
......
......@@ -432,7 +432,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return this.fileService.resolveContent(resource, { acceptTextOnly: true }).then(null, error => {
if ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {
return this.fileService.updateContent(resource, contents).then(null, error => {
return TPromise.wrapError(new Error(nls.localize('fail.createSettings', "Unable to create '{0}' ({1}).", labels.getPathLabel(resource, this.contextService, this.environmentService), error)));
return TPromise.wrapError(new Error(nls.localize('fail.createSettings', "Unable to create '{0}' ({1}).", labels.getPathLabel(resource, this.environmentService, this.contextService), error)));
});
}
......
......@@ -21,7 +21,7 @@ import { Range } from 'vs/editor/common/core/range';
import { Position } from 'vs/editor/common/core/position';
import { IModelService } from 'vs/editor/common/services/modelService';
import { EditOperation } from 'vs/editor/common/core/editOperation';
import { TestFileService, TestEditorService, TestEditorGroupsService } from 'vs/workbench/test/workbenchTestServices';
import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService } from 'vs/workbench/test/workbenchTestServices';
import { TPromise } from 'vs/base/common/winjs.base';
import { IFileStat } from 'vs/platform/files/common/files';
import { ResourceTextEdit } from 'vs/editor/common/modes';
......@@ -73,7 +73,7 @@ suite('MainThreadEditors', () => {
const workbenchEditorService = new TestEditorService();
const editorGroupService = new TestEditorGroupsService();
const bulkEditService = new BulkEditService(modelService, new TestEditorService(), null, fileService);
const bulkEditService = new BulkEditService(modelService, new TestEditorService(), null, fileService, TestEnvironmentService);
const rpcProtocol = new TestRPCProtocol();
rpcProtocol.set(ExtHostContext.ExtHostDocuments, new class extends mock<ExtHostDocumentsShape>() {
......@@ -156,4 +156,3 @@ function createMockFileStat(target: URI): IFileStat {
resource: target
};
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册