提交 9afde2fc 编写于 作者: B Benjamin Pasero

FileLabel can't handle UNC paths very well (fixes #24235)

上级 246d39b2
......@@ -9,7 +9,7 @@ import platform = require('vs/base/common/platform');
import types = require('vs/base/common/types');
import { nativeSep, normalize } from 'vs/base/common/paths';
import { endsWith, ltrim } from 'vs/base/common/strings';
import { isEqualOrParent } from 'vs/platform/files/common/files';
import { isEqualOrParent, isEqual } from 'vs/platform/files/common/files';
export interface ILabelProvider {
......@@ -46,7 +46,7 @@ export function getPathLabel(resource: URI | string, basePathProvider?: URI | st
const basepath = basePathProvider && getPath(basePathProvider);
if (basepath && isEqualOrParent(absolutePath, basepath, !platform.isLinux /* ignorecase */)) {
if (basepath === absolutePath) {
if (isEqual(basepath, absolutePath, !platform.isLinux /* ignorecase */)) {
return ''; // no label if pathes are identical
}
......@@ -78,7 +78,7 @@ function getPath(arg1: URI | string | IWorkspaceProvider): string {
}
export function tildify(path: string, userHome: string): string {
if (path && (platform.isMacintosh || platform.isLinux) && path.indexOf(userHome) === 0) {
if (path && (platform.isMacintosh || platform.isLinux) && isEqualOrParent(path, userHome, !platform.isLinux /* ignorecase */)) {
path = `~${path.substr(userHome.length)}`;
}
......
......@@ -7,8 +7,6 @@
import 'vs/css!./welcomePage';
import URI from 'vs/base/common/uri';
import * as path from 'path';
import * as platform from 'vs/base/common/platform';
import * as strings from 'vs/base/common/strings';
import * as arrays from 'vs/base/common/arrays';
import { WalkThroughInput } from 'vs/workbench/parts/welcome/walkThrough/node/walkThroughInput';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
......@@ -34,6 +32,7 @@ import { IExtensionEnablementService, IExtensionManagementService, IExtensionGal
import { used } from 'vs/workbench/parts/welcome/page/electron-browser/vs_code_welcome_page';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { tildify } from "vs/base/common/labels";
used();
......@@ -146,7 +145,7 @@ class WelcomePage {
.then(null, error => this.messageService.show(Severity.Error, error));
});
recentlyOpened.then(({folders}) => {
recentlyOpened.then(({ folders }) => {
if (this.contextService.hasWorkspace()) {
const current = this.contextService.getWorkspace().resource.fsPath;
folders = folders.filter(folder => folder !== current);
......@@ -184,10 +183,7 @@ class WelcomePage {
const span = document.createElement('span');
span.classList.add('path');
if ((platform.isMacintosh || platform.isLinux) && strings.startsWith(parentFolder, this.environmentService.userHome)) {
parentFolder = `~${parentFolder.substr(this.environmentService.userHome.length)}`;
}
span.innerText = parentFolder;
span.innerText = tildify(parentFolder, this.environmentService.userHome);
span.title = folder;
li.appendChild(span);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册