Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
305f0fbb
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,发现更多精彩内容 >>
提交
305f0fbb
编写于
3月 03, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
editorInput.getTitle() for #16623
上级
434da15e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
68 addition
and
43 deletion
+68
-43
src/vs/base/common/labels.ts
src/vs/base/common/labels.ts
+8
-0
src/vs/platform/editor/common/editor.ts
src/vs/platform/editor/common/editor.ts
+11
-0
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
+5
-4
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
+5
-5
src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
+6
-15
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+6
-4
src/vs/workbench/parts/files/common/editors/fileEditorInput.ts
...s/workbench/parts/files/common/editors/fileEditorInput.ts
+25
-14
src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts
...orkbench/parts/files/test/browser/fileEditorInput.test.ts
+2
-1
未找到文件。
src/vs/base/common/labels.ts
浏览文件 @
305f0fbb
...
...
@@ -76,6 +76,14 @@ function getPath(arg1: URI | string | IWorkspaceProvider): string {
return
(
<
URI
>
arg1
).
fsPath
;
}
export
function
tildify
(
path
:
string
,
userHome
:
string
):
string
{
if
(
path
&&
(
platform
.
isMacintosh
||
platform
.
isLinux
)
&&
path
.
indexOf
(
userHome
)
===
0
)
{
path
=
`~
${
path
.
substr
(
userHome
.
length
)}
`
;
}
return
path
;
}
/**
* Shortens the paths but keeps them easy to distinguish.
* Replaces not important parts with ellipsis.
...
...
src/vs/platform/editor/common/editor.ts
浏览文件 @
305f0fbb
...
...
@@ -159,6 +159,12 @@ export enum Direction {
RIGHT
}
export
enum
Verbosity
{
SHORT
,
MEDIUM
,
LONG
}
export
interface
IEditorInput
extends
IDisposable
{
onDispose
:
Event
<
void
>
;
...
...
@@ -173,6 +179,11 @@ export interface IEditorInput extends IDisposable {
*/
getDescription
(
verbose
?:
boolean
):
string
;
/**
* Returns the display title of this input.
*/
getTitle
(
verbosity
?:
Verbosity
):
string
;
/**
* Resolves the input.
*/
...
...
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
浏览文件 @
305f0fbb
...
...
@@ -11,6 +11,7 @@ import { IEditorGroup, toResource } from 'vs/workbench/common/editor';
import
DOM
=
require
(
'
vs/base/browser/dom
'
);
import
{
TitleControl
}
from
'
vs/workbench/browser/parts/editor/titleControl
'
;
import
{
EditorLabel
}
from
'
vs/workbench/browser/labels
'
;
import
{
Verbosity
}
from
'
vs/platform/editor/common/editor
'
;
export
class
NoTabsTitleControl
extends
TitleControl
{
private
titleContainer
:
HTMLElement
;
...
...
@@ -119,12 +120,12 @@ export class NoTabsTitleControl extends TitleControl {
const
resource
=
toResource
(
editor
,
{
supportSideBySide
:
true
});
const
name
=
editor
.
getName
()
||
''
;
const
description
=
isActive
?
(
editor
.
getDescription
()
||
''
)
:
''
;
let
verboseDescription
=
editor
.
getDescription
(
true
)
||
''
;
if
(
description
===
verboseDescription
)
{
verboseDescription
=
''
;
// dont repeat what is already shown
let
title
=
editor
.
getTitle
(
Verbosity
.
LONG
)
;
if
(
description
===
title
)
{
title
=
''
;
// dont repeat what is already shown
}
this
.
editorLabel
.
setLabel
({
name
,
description
,
resource
},
{
title
:
verboseDescription
,
italic
:
!
isPinned
,
extraClasses
:
[
'
title-label
'
]
});
this
.
editorLabel
.
setLabel
({
name
,
description
,
resource
},
{
title
,
italic
:
!
isPinned
,
extraClasses
:
[
'
title-label
'
]
});
// Update Editor Actions Toolbar
this
.
updateEditorActionsToolbar
();
...
...
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
浏览文件 @
305f0fbb
...
...
@@ -14,7 +14,7 @@ import { isMacintosh } from 'vs/base/common/platform';
import
{
MIME_BINARY
}
from
'
vs/base/common/mime
'
;
import
{
shorten
}
from
'
vs/base/common/labels
'
;
import
{
ActionRunner
,
IAction
}
from
'
vs/base/common/actions
'
;
import
{
Position
,
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Position
,
IEditorInput
,
Verbosity
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorGroup
,
toResource
}
from
'
vs/workbench/common/editor
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
...
...
@@ -44,7 +44,7 @@ interface IEditorInputLabel {
name
:
string
;
hasAmbiguousName
?:
boolean
;
description
?:
string
;
verboseDescription
?:
string
;
title
?:
string
;
}
export
class
TabsTitleControl
extends
TitleControl
{
...
...
@@ -211,11 +211,11 @@ export class TabsTitleControl extends TitleControl {
const
label
=
labels
[
index
];
const
name
=
label
.
name
;
const
description
=
label
.
hasAmbiguousName
&&
label
.
description
?
label
.
description
:
''
;
const
verboseDescription
=
label
.
verboseDescription
||
''
;
const
title
=
label
.
title
||
''
;
// Container
tabContainer
.
setAttribute
(
'
aria-label
'
,
`
${
name
}
, tab`
);
tabContainer
.
title
=
verboseDescription
;
tabContainer
.
title
=
title
;
[
'
off
'
,
'
left
'
].
forEach
(
option
=>
{
const
domAction
=
this
.
tabOptions
.
tabCloseButton
===
option
?
DOM
.
addClass
:
DOM
.
removeClass
;
domAction
(
tabContainer
,
`close-button-
${
option
}
`
);
...
...
@@ -264,7 +264,7 @@ export class TabsTitleControl extends TitleControl {
editor
,
name
:
editor
.
getName
(),
description
,
verboseDescription
:
editor
.
getDescription
(
true
)
title
:
editor
.
getTitle
(
Verbosity
.
LONG
)
};
labels
.
push
(
item
);
...
...
src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
浏览文件 @
305f0fbb
...
...
@@ -23,12 +23,12 @@ import { IIntegrityService } from 'vs/platform/integrity/common/integrity';
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
isMacintosh
,
isLinux
}
from
'
vs/base/common/platform
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
*
as
labels
from
'
vs/base/common/labels
'
;
import
{
EditorInput
,
toResource
}
from
'
vs/workbench/common/editor
'
;
import
{
EditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
Verbosity
}
from
'
vs/platform/editor/common/editor
'
;
export
class
TitlebarPart
extends
Part
implements
ITitleService
{
...
...
@@ -66,7 +66,7 @@ export class TitlebarPart extends Part implements ITitleService {
this
.
isPure
=
true
;
this
.
activeEditorListeners
=
[];
this
.
workspacePath
=
contextService
.
hasWorkspace
()
?
this
.
tildify
(
labels
.
getPathLabel
(
contextService
.
getWorkspace
().
resource
)
)
:
''
;
this
.
workspacePath
=
contextService
.
hasWorkspace
()
?
labels
.
tildify
(
labels
.
getPathLabel
(
contextService
.
getWorkspace
().
resource
),
environmentService
.
userHome
)
:
''
;
this
.
init
();
...
...
@@ -163,12 +163,11 @@ export class TitlebarPart extends Part implements ITitleService {
private
doGetWindowTitle
():
string
{
const
input
=
this
.
editorService
.
getActiveEditorInput
();
const
workspace
=
this
.
contextService
.
getWorkspace
();
const
file
=
toResource
(
input
,
{
filter
:
'
file
'
});
// Variables
const
activeEditorShort
=
input
?
input
.
get
Name
(
)
:
''
;
const
activeEditorMedium
=
file
?
labels
.
getPathLabel
(
file
,
this
.
contextService
)
:
activeEditorShort
;
const
activeEditorLong
=
file
?
this
.
tildify
(
labels
.
getPathLabel
(
file
)
)
:
activeEditorMedium
;
const
activeEditorShort
=
input
?
input
.
get
Title
(
Verbosity
.
SHORT
)
:
''
;
const
activeEditorMedium
=
input
?
input
.
getTitle
(
Verbosity
.
MEDIUM
)
:
activeEditorShort
;
const
activeEditorLong
=
input
?
input
.
getTitle
(
Verbosity
.
LONG
)
:
activeEditorMedium
;
const
rootName
=
workspace
?
workspace
.
name
:
''
;
const
rootPath
=
workspace
?
this
.
workspacePath
:
''
;
const
dirty
=
input
&&
input
.
isDirty
()
?
TitlebarPart
.
TITLE_DIRTY
:
''
;
...
...
@@ -187,14 +186,6 @@ export class TitlebarPart extends Part implements ITitleService {
});
}
private
tildify
(
path
:
string
):
string
{
if
(
path
&&
(
isMacintosh
||
isLinux
)
&&
path
.
indexOf
(
this
.
environmentService
.
userHome
)
===
0
)
{
path
=
`~
${
path
.
substr
(
this
.
environmentService
.
userHome
.
length
)}
`
;
}
return
path
;
}
public
createContentArea
(
parent
:
Builder
):
Builder
{
this
.
titleContainer
=
$
(
parent
);
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
305f0fbb
...
...
@@ -11,7 +11,7 @@ import types = require('vs/base/common/types');
import
URI
from
'
vs/base/common/uri
'
;
import
{
IDisposable
,
dispose
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IEditor
,
ICommonCodeEditor
,
IEditorViewState
,
IEditorOptions
as
ICodeEditorOptions
,
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorInput
,
IEditorModel
,
IEditorOptions
,
ITextEditorOptions
,
IBaseResourceInput
,
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorInput
,
IEditorModel
,
IEditorOptions
,
ITextEditorOptions
,
IBaseResourceInput
,
Position
,
Verbosity
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
SyncDescriptor
,
AsyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
...
...
@@ -179,13 +179,15 @@ export abstract class EditorInput implements IEditorInput {
/**
* Returns the description of this input that can be shown to the user. Examples include showing the description of
* the input above the editor area to the side of the name of the input.
*
* @param verbose controls if the description should be short or can contain additional details.
*/
public
getDescription
(
verbose
?:
boolean
):
string
{
public
getDescription
():
string
{
return
null
;
}
public
getTitle
(
verbosity
?:
Verbosity
):
string
{
return
this
.
getName
();
}
/**
* Returns the unique type identifier of this input.
*/
...
...
src/vs/workbench/parts/files/common/editors/fileEditorInput.ts
浏览文件 @
305f0fbb
...
...
@@ -18,6 +18,8 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
telemetryURIDescriptor
}
from
'
vs/platform/telemetry/common/telemetryUtils
'
;
import
{
Verbosity
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
/**
* A file editor input is the input type for the file editor of file system resources.
...
...
@@ -29,7 +31,10 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
private
name
:
string
;
private
description
:
string
;
private
verboseDescription
:
string
;
private
shortTitle
:
string
;
private
mediumTitle
:
string
;
private
longTitle
:
string
;
private
toUnbind
:
IDisposable
[];
...
...
@@ -41,7 +46,8 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
preferredEncoding
:
string
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
ITextFileService
private
textFileService
:
ITextFileService
@
ITextFileService
private
textFileService
:
ITextFileService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
)
{
super
();
...
...
@@ -76,7 +82,9 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
// Reset resource dependent properties
this
.
name
=
null
;
this
.
description
=
null
;
this
.
verboseDescription
=
null
;
this
.
shortTitle
=
null
;
this
.
mediumTitle
=
null
;
this
.
longTitle
=
null
;
}
public
getResource
():
URI
{
...
...
@@ -125,20 +133,23 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
return
this
.
name
;
}
public
getDescription
(
verbose
?:
boolean
):
string
{
if
(
!
verbose
)
{
if
(
!
this
.
description
)
{
this
.
description
=
labels
.
getPathLabel
(
paths
.
dirname
(
this
.
resource
.
fsPath
),
this
.
contextService
);
}
return
this
.
description
;
public
getDescription
():
string
{
if
(
!
this
.
description
)
{
this
.
description
=
labels
.
getPathLabel
(
paths
.
dirname
(
this
.
resource
.
fsPath
),
this
.
contextService
);
}
if
(
!
this
.
verboseDescription
)
{
this
.
verboseDescription
=
labels
.
getPathLabel
(
this
.
resource
.
fsPath
);
}
return
this
.
description
;
}
return
this
.
verboseDescription
;
public
getTitle
(
verbosity
:
Verbosity
):
string
{
switch
(
verbosity
)
{
case
Verbosity
.
SHORT
:
return
this
.
shortTitle
?
this
.
shortTitle
:
(
this
.
shortTitle
=
this
.
getName
());
case
Verbosity
.
MEDIUM
:
return
this
.
mediumTitle
?
this
.
mediumTitle
:
(
this
.
mediumTitle
=
labels
.
getPathLabel
(
this
.
resource
,
this
.
contextService
));
case
Verbosity
.
LONG
:
return
this
.
longTitle
?
this
.
longTitle
:
(
this
.
longTitle
=
labels
.
tildify
(
labels
.
getPathLabel
(
this
.
resource
),
this
.
environmentService
.
userHome
));
}
}
public
isDirty
():
boolean
{
...
...
src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts
浏览文件 @
305f0fbb
...
...
@@ -15,6 +15,7 @@ import { EncodingMode } from 'vs/workbench/common/editor';
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
FileOperationResult
,
IFileOperationResult
}
from
'
vs/platform/files/common/files
'
;
import
{
TextFileEditorModel
}
from
'
vs/workbench/services/textfile/common/textFileEditorModel
'
;
import
{
Verbosity
}
from
'
vs/platform/editor/common/editor
'
;
function
toResource
(
path
)
{
return
URI
.
file
(
join
(
'
C:
\\
'
,
new
Buffer
(
this
.
test
.
fullTitle
()).
toString
(
'
base64
'
),
path
));
...
...
@@ -49,7 +50,7 @@ suite('Files - FileEditorInput', () => {
assert
(
!
input
.
matches
(
null
));
assert
.
ok
(
input
.
getName
());
assert
.
ok
(
input
.
getDescription
());
assert
.
ok
(
input
.
get
Description
(
true
));
assert
.
ok
(
input
.
get
Title
(
Verbosity
.
SHORT
));
assert
.
strictEqual
(
'
file.js
'
,
input
.
getName
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录