Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
2e54e849
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2e54e849
编写于
8月 15, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shorter tab labels for #8499
上级
3efdbfd6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
66 addition
and
38 deletion
+66
-38
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
+64
-4
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+2
-34
未找到文件。
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
浏览文件 @
2e54e849
...
...
@@ -11,8 +11,8 @@ import errors = require('vs/base/common/errors');
import
DOM
=
require
(
'
vs/base/browser/dom
'
);
import
{
isMacintosh
}
from
'
vs/base/common/platform
'
;
import
{
MIME_BINARY
}
from
'
vs/base/common/mime
'
;
import
{
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorGroup
,
IEditorIdentifier
,
asFileEditorInput
,
getUniqueLabels
}
from
'
vs/workbench/common/editor
'
;
import
{
Position
,
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorGroup
,
IEditorIdentifier
,
asFileEditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
CommonKeybindings
as
Kb
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
ActionBar
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
...
...
@@ -33,6 +33,16 @@ import {IDisposable, dispose} from 'vs/base/common/lifecycle';
import
{
ScrollableElement
}
from
'
vs/base/browser/ui/scrollbar/scrollableElement
'
;
import
{
ScrollbarVisibility
}
from
'
vs/base/common/scrollable
'
;
import
{
extractResources
}
from
'
vs/base/browser/dnd
'
;
import
{
LinkedMap
}
from
'
vs/base/common/map
'
;
import
paths
=
require
(
'
vs/base/common/paths
'
);
interface
IEditorInputLabel
{
editor
:
IEditorInput
;
name
:
string
;
hasAmbiguousName
?:
boolean
;
description
?:
string
;
verboseDescription
?:
string
;
}
export
class
TabsTitleControl
extends
TitleControl
{
private
titleContainer
:
HTMLElement
;
...
...
@@ -182,7 +192,7 @@ export class TabsTitleControl extends TitleControl {
// Compute labels and protect against duplicates
const
editorsOfGroup
=
this
.
context
.
getEditors
();
const
labels
=
getUnique
Labels
(
editorsOfGroup
);
const
labels
=
this
.
getUniqueTab
Labels
(
editorsOfGroup
);
// Tab label and styles
editorsOfGroup
.
forEach
((
editor
,
index
)
=>
{
...
...
@@ -198,7 +208,7 @@ export class TabsTitleControl extends TitleControl {
const
label
=
labels
[
index
];
const
name
=
label
.
name
;
const
description
=
label
.
hasAmbiguosName
&&
label
.
description
?
label
.
description
:
''
;
const
description
=
label
.
hasAmbiguo
u
sName
&&
label
.
description
?
label
.
description
:
''
;
const
verboseDescription
=
label
.
verboseDescription
||
''
;
// Label & Description
...
...
@@ -245,6 +255,56 @@ export class TabsTitleControl extends TitleControl {
this
.
layout
();
}
private
getUniqueTabLabels
(
editors
:
IEditorInput
[]):
IEditorInputLabel
[]
{
const
labels
:
IEditorInputLabel
[]
=
[];
const
mapLabelToDuplicates
=
new
LinkedMap
<
string
,
IEditorInputLabel
[]
>
();
const
mapDescriptionToDuplicates
=
new
LinkedMap
<
string
,
IEditorInputLabel
[]
>
();
// Build labels and descriptions for each editor
editors
.
forEach
(
editor
=>
{
let
description
=
editor
.
getDescription
();
if
(
description
&&
description
.
indexOf
(
paths
.
nativeSep
)
>=
0
)
{
description
=
paths
.
basename
(
description
);
// optimize for editors that show paths and build a shorter description to keep tab width small
}
const
item
:
IEditorInputLabel
=
{
editor
,
name
:
editor
.
getName
(),
description
,
verboseDescription
:
editor
.
getDescription
(
true
)
};
labels
.
push
(
item
);
mapLabelToDuplicates
.
getOrSet
(
item
.
name
,
[]).
push
(
item
);
if
(
item
.
description
)
{
mapDescriptionToDuplicates
.
getOrSet
(
item
.
description
,
[]).
push
(
item
);
}
});
// Mark label duplicates
const
labelDuplicates
=
mapLabelToDuplicates
.
values
();
labelDuplicates
.
forEach
(
duplicates
=>
{
if
(
duplicates
.
length
>
1
)
{
duplicates
.
forEach
(
duplicate
=>
{
duplicate
.
hasAmbiguousName
=
true
;
});
}
});
// React to description duplicates
const
descriptionDuplicates
=
mapDescriptionToDuplicates
.
values
();
descriptionDuplicates
.
forEach
(
duplicates
=>
{
if
(
duplicates
.
length
>
1
)
{
duplicates
.
forEach
(
duplicate
=>
{
duplicate
.
description
=
duplicate
.
editor
.
getDescription
();
// fallback to full description if the short description still has duplicates
});
}
});
return
labels
;
}
protected
doRefresh
():
void
{
const
group
=
this
.
context
;
const
editor
=
group
&&
group
.
activeEditor
;
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
2e54e849
...
...
@@ -16,7 +16,6 @@ import {Event as BaseEvent} from 'vs/base/common/events';
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
SyncDescriptor
,
AsyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
IInstantiationService
,
IConstructorSignature0
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
LinkedMap
}
from
'
vs/base/common/map
'
;
export
enum
ConfirmResult
{
SAVE
,
...
...
@@ -694,7 +693,7 @@ export function getUntitledOrFileResource(input: IEditorInput, supportDiff?: boo
}
export
function
getResource
(
input
:
IEditorInput
):
URI
{
if
(
input
&&
typeof
(
<
any
>
input
).
getResource
===
'
function
'
)
{
if
(
input
&&
typeof
(
<
any
>
input
).
getResource
===
'
function
'
)
{
let
candidate
=
(
<
any
>
input
).
getResource
();
if
(
candidate
instanceof
URI
)
{
return
candidate
;
...
...
@@ -845,35 +844,4 @@ export interface ActiveEditorMoveArguments {
export
var
EditorCommands
=
{
MoveActiveEditor
:
'
moveActiveEditor
'
};
export
interface
IEditorInputLabel
{
name
:
string
;
hasAmbiguosName
?:
boolean
;
description
?:
string
;
verboseDescription
?:
string
;
}
export
function
getUniqueLabels
(
editors
:
IEditorInput
[]):
IEditorInputLabel
[]
{
const
labels
:
IEditorInputLabel
[]
=
[];
const
mapLabelToDuplicates
=
new
LinkedMap
<
string
,
IEditorInputLabel
[]
>
();
editors
.
forEach
(
editor
=>
{
const
item
:
IEditorInputLabel
=
{
name
:
editor
.
getName
(),
description
:
editor
.
getDescription
(),
verboseDescription
:
editor
.
getDescription
(
true
)
};
labels
.
push
(
item
);
const
duplicates
=
mapLabelToDuplicates
.
getOrSet
(
item
.
name
,
[]);
duplicates
.
push
(
item
);
});
const
duplicates
=
mapLabelToDuplicates
.
values
();
duplicates
.
forEach
(
duplicates
=>
{
if
(
duplicates
.
length
>
1
)
{
duplicates
.
forEach
(
duplicate
=>
{
duplicate
.
hasAmbiguosName
=
true
;
});
}
});
return
labels
;
}
\ No newline at end of file
};
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录