Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
3ddce413
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3ddce413
编写于
1月 15, 2017
作者:
H
hun1ahpu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix labels unit tests + root displayed as '..
上级
3d71a325
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
43 deletion
+43
-43
src/vs/base/common/labels.ts
src/vs/base/common/labels.ts
+7
-4
src/vs/base/test/common/labels.test.ts
src/vs/base/test/common/labels.test.ts
+36
-39
未找到文件。
src/vs/base/common/labels.ts
浏览文件 @
3ddce413
...
...
@@ -83,19 +83,22 @@ function getPath(arg1: URI | string | IWorkspaceProvider): string {
*/
export
function
shorten
(
paths
:
string
[]):
string
[]
{
const
ellipsis
=
'
\
u2026
'
;
const
separator
=
'
/
'
;
const
shortenedPaths
:
string
[]
=
new
Array
(
paths
.
length
);
paths
=
paths
.
map
(
path
=>
normalize
(
path
));
// for every path
let
match
=
false
;
for
(
let
pathIndex
=
0
;
pathIndex
<
paths
.
length
;
pathIndex
++
)
{
const
segments
:
string
[]
=
paths
[
pathIndex
].
split
(
nativeSep
);
const
segments
:
string
[]
=
paths
[
pathIndex
].
split
(
separator
);
match
=
true
;
// pick the first shortest subpath found
for
(
let
subpathLength
=
1
;
match
&&
subpathLength
<=
segments
.
length
;
subpathLength
++
)
{
for
(
let
start
=
segments
.
length
-
subpathLength
;
match
&&
start
>=
0
;
start
--
)
{
match
=
false
;
const
subpath
=
segments
.
slice
(
start
,
start
+
subpathLength
).
join
(
nativeSep
);
const
subpath
=
segments
.
slice
(
start
,
start
+
subpathLength
).
join
(
separator
);
// that is unique to any other path
for
(
let
otherPathIndex
=
0
;
!
match
&&
otherPathIndex
<
paths
.
length
;
otherPathIndex
++
)
{
...
...
@@ -113,11 +116,11 @@ export function shorten(paths: string[]): string[] {
if
(
!
match
)
{
let
result
=
subpath
;
if
(
start
+
subpathLength
<
segments
.
length
)
{
result
=
result
+
nativeSep
+
ellipsis
;
result
=
result
+
separator
+
ellipsis
;
}
if
(
start
>
0
)
{
result
=
ellipsis
+
nativeSep
+
result
;
result
=
ellipsis
+
separator
+
result
;
}
shortenedPaths
[
pathIndex
]
=
result
;
...
...
src/vs/base/test/common/labels.test.ts
浏览文件 @
3ddce413
...
...
@@ -6,48 +6,45 @@
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
//
import labels = require('vs/base/common/labels');
import
labels
=
require
(
'
vs/base/common/labels
'
);
suite
(
'
Labels
'
,
()
=>
{
test
(
'
shorten
'
,
()
=>
{
assert
.
ok
(
true
);
// nothing to shorten
// assert.deepEqual(labels.shorten(['a']), ['a']);
// assert.deepEqual(labels.shorten(['a', 'b']), ['a', 'b']);
// assert.deepEqual(labels.shorten(['a', 'b', 'c']), ['a', 'b', 'c']);
// // completely different paths
// assert.deepEqual(labels.shorten(['a\\b', 'c\\d', 'e\\f']), ['…\\b', '…\\d', '…\\f']);
// // same beginning
// assert.deepEqual(labels.shorten(['a', 'a\\b']), ['a', '…\\b']);
// assert.deepEqual(labels.shorten(['a\\b', 'a\\b\\c']), ['…\\b', '…\\c']);
// assert.deepEqual(labels.shorten(['a', 'a\\b', 'a\\b\\c']), ['a', '…\\b', '…\\c']);
// assert.deepEqual(labels.shorten(['x:\\a\\b', 'x:\\a\\c']), ['…\\b', '…\\c'], 'TODO: drive letter (or schema) should be preserved');
// assert.deepEqual(labels.shorten(['\\\\a\\b', '\\\\a\\c']), ['…\\b', '…\\c'], 'TODO: root uri should be preserved');
// // same ending
// assert.deepEqual(labels.shorten(['a', 'b\\a']), ['a', 'b\\…']);
// assert.deepEqual(labels.shorten(['a\\b\\c', 'd\\b\\c']), ['a\\…', 'd\\…']);
// assert.deepEqual(labels.shorten(['a\\b\\c\\d', 'f\\b\\c\\d']), ['a\\…', 'f\\…']);
// assert.deepEqual(labels.shorten(['d\\e\\a\\b\\c', 'd\\b\\c']), ['…\\a\\…', 'd\\b\\…']);
// assert.deepEqual(labels.shorten(['a\\b\\c\\d', 'a\\f\\b\\c\\d']), ['a\\b\\…', '…\\f\\…']);
// assert.deepEqual(labels.shorten(['a\\b\\a', 'b\\b\\a']), ['a\\b\\…', 'b\\b\\…']);
// assert.deepEqual(labels.shorten(['d\\f\\a\\b\\c', 'h\\d\\b\\c']), ['…\\a\\…', 'h\\…']);
// assert.deepEqual(labels.shorten(['a\\b\\c', 'x:\\0\\a\\b\\c']), ['a\\b\\c', '…\\0\\…'], 'TODO: drive letter (or schema) should be always preserved');
// assert.deepEqual(labels.shorten(['x:\\a\\b', 'y:\\a\\b']), ['x:\\…', 'y:\\…']);
// assert.deepEqual(labels.shorten(['\\\\x\\b', '\\\\y\\b']), ['…\\x\\…', '…\\y\\…'], 'TODO: \\\\x instead of …\\x');
// // same in the middle
// assert.deepEqual(labels.shorten(['a\\b\\c', 'd\\b\\e']), ['…\\c', '…\\e']);
// // case-sensetive
// assert.deepEqual(labels.shorten(['a\\b\\c', 'd\\b\\C']), ['…\\c', '…\\C']);
// assert.deepEqual(labels.shorten(['a', 'a\\b', 'a\\b\\c', 'd\\b\\c', 'd\\b']), ['a', 'a\\b', 'a\\b\\c', 'd\\b\\c', 'd\\b']);
// assert.deepEqual(labels.shorten(['a', 'a\\b', 'b']), ['a', 'a\\b', 'b']);
// assert.deepEqual(labels.shorten(['', 'a', 'b', 'b\\c', 'a\\c']), ['', 'a', 'b', 'b\\c', 'a\\c']);
// assert.deepEqual(labels.shorten(['src\\vs\\workbench\\parts\\execution\\electron-browser', 'src\\vs\\workbench\\parts\\execution\\electron-browser\\something', 'src\\vs\\workbench\\parts\\terminal\\electron-browser']), ['…\\execution\\electron-browser', '…\\something', '…\\terminal\\…']);
assert
.
deepEqual
(
labels
.
shorten
([
'
a
'
]),
[
'
a
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
a
'
,
'
b
'
]),
[
'
a
'
,
'
b
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
a
'
,
'
b
'
,
'
c
'
]),
[
'
a
'
,
'
b
'
,
'
c
'
]);
// completely different paths
assert
.
deepEqual
(
labels
.
shorten
([
'
a/b
'
,
'
c/d
'
,
'
e/f
'
]),
[
'
…/b
'
,
'
…/d
'
,
'
…/f
'
]);
// same beginning
assert
.
deepEqual
(
labels
.
shorten
([
'
a
'
,
'
a/b
'
]),
[
'
a
'
,
'
…/b
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
a/b
'
,
'
a/b/c
'
]),
[
'
…/b
'
,
'
…/c
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
a
'
,
'
a/b
'
,
'
a/b/c
'
]),
[
'
a
'
,
'
…/b
'
,
'
…/c
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
x:/a/b
'
,
'
x:/a/c
'
]),
[
'
…/b
'
,
'
…/c
'
],
'
TODO: drive letter (or schema) should be preserved
'
);
assert
.
deepEqual
(
labels
.
shorten
([
'
//a/b
'
,
'
//a/c
'
]),
[
'
…/b
'
,
'
…/c
'
],
'
TODO: root uri should be preserved
'
);
// same ending
assert
.
deepEqual
(
labels
.
shorten
([
'
a
'
,
'
b/a
'
]),
[
'
a
'
,
'
b/…
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
a/b/c
'
,
'
d/b/c
'
]),
[
'
a/…
'
,
'
d/…
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
a/b/c/d
'
,
'
f/b/c/d
'
]),
[
'
a/…
'
,
'
f/…
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
d/e/a/b/c
'
,
'
d/b/c
'
]),
[
'
…/a/…
'
,
'
d/b/…
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
a/b/c/d
'
,
'
a/f/b/c/d
'
]),
[
'
a/b/…
'
,
'
…/f/…
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
a/b/a
'
,
'
b/b/a
'
]),
[
'
a/b/…
'
,
'
b/b/…
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
d/f/a/b/c
'
,
'
h/d/b/c
'
]),
[
'
…/a/…
'
,
'
h/…
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
a/b/c
'
,
'
x:/0/a/b/c
'
]),
[
'
a/b/c
'
,
'
…/0/…
'
],
'
TODO: drive letter (or schema) should be always preserved
'
);
assert
.
deepEqual
(
labels
.
shorten
([
'
x:/a/b
'
,
'
y:/a/b
'
]),
[
'
x:/…
'
,
'
y:/…
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
//x/b
'
,
'
//y/b
'
]),
[
'
…/x/…
'
,
'
…/y/…
'
],
'
TODO: //x instead of …/x
'
);
// same in the middle
assert
.
deepEqual
(
labels
.
shorten
([
'
a/b/c
'
,
'
d/b/e
'
]),
[
'
…/c
'
,
'
…/e
'
]);
// case-sensitive
assert
.
deepEqual
(
labels
.
shorten
([
'
a/b/c
'
,
'
d/b/C
'
]),
[
'
…/c
'
,
'
…/C
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
a
'
,
'
a/b
'
,
'
a/b/c
'
,
'
d/b/c
'
,
'
d/b
'
]),
[
'
a
'
,
'
a/b
'
,
'
a/b/c
'
,
'
d/b/c
'
,
'
d/b
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
'
a
'
,
'
a/b
'
,
'
b
'
]),
[
'
a
'
,
'
a/b
'
,
'
b
'
]);
assert
.
deepEqual
(
labels
.
shorten
([
''
,
'
a
'
,
'
b
'
,
'
b/c
'
,
'
a/c
'
]),
[
'
.
'
,
'
a
'
,
'
b
'
,
'
b/c
'
,
'
a/c
'
]);
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录