Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9ba00291
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,体验更适合开发者的 AI 搜索 >>
提交
9ba00291
编写于
9月 29, 2018
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
labelservice: match prefix, take longest match
上级
39bff6cf
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
31 addition
and
19 deletion
+31
-19
src/vs/code/electron-main/app.ts
src/vs/code/electron-main/app.ts
+1
-1
src/vs/editor/standalone/browser/simpleServices.ts
src/vs/editor/standalone/browser/simpleServices.ts
+1
-1
src/vs/platform/label/common/label.ts
src/vs/platform/label/common/label.ts
+24
-10
src/vs/platform/label/test/label.test.ts
src/vs/platform/label/test/label.test.ts
+2
-3
src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts
...vs/workbench/api/electron-browser/mainThreadFileSystem.ts
+2
-2
src/vs/workbench/parts/files/electron-browser/files.contribution.ts
...kbench/parts/files/electron-browser/files.contribution.ts
+1
-2
未找到文件。
src/vs/code/electron-main/app.ts
浏览文件 @
9ba00291
...
...
@@ -236,7 +236,7 @@ export class CodeApplication {
});
ipc
.
on
(
'
vscode:labelRegisterFormatter
'
,
(
event
:
any
,
data
:
RegisterFormatterEvent
)
=>
{
this
.
labelService
.
registerFormatter
(
data
.
s
cheme
,
data
.
formatter
);
this
.
labelService
.
registerFormatter
(
data
.
s
elector
,
data
.
formatter
);
});
ipc
.
on
(
'
vscode:toggleDevTools
'
,
(
event
:
Event
)
=>
{
...
...
src/vs/editor/standalone/browser/simpleServices.ts
浏览文件 @
9ba00291
...
...
@@ -613,7 +613,7 @@ export class SimpleUriLabelService implements ILabelService {
return
''
;
}
public
registerFormatter
(
s
chema
:
string
,
formatter
:
LabelRules
):
IDisposable
{
public
registerFormatter
(
s
elector
:
string
,
formatter
:
LabelRules
):
IDisposable
{
throw
new
Error
(
'
Not implemented
'
);
}
}
src/vs/platform/label/common/label.ts
浏览文件 @
9ba00291
...
...
@@ -12,7 +12,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
import
{
isEqual
,
basenameOrAuthority
}
from
'
vs/base/common/resources
'
;
import
{
isLinux
,
isWindows
}
from
'
vs/base/common/platform
'
;
import
{
tildify
,
getPathLabel
}
from
'
vs/base/common/labels
'
;
import
{
ltrim
}
from
'
vs/base/common/strings
'
;
import
{
ltrim
,
startsWith
}
from
'
vs/base/common/strings
'
;
import
{
IWorkspaceIdentifier
,
ISingleFolderWorkspaceIdentifier
,
isSingleFolderWorkspaceIdentifier
,
WORKSPACE_EXTENSION
,
toWorkspaceIdentifier
,
isWorkspaceIdentifier
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
isParent
}
from
'
vs/platform/files/common/files
'
;
...
...
@@ -20,7 +20,7 @@ import { basename, dirname, join } from 'vs/base/common/paths';
import
{
Schemas
}
from
'
vs/base/common/network
'
;
export
interface
RegisterFormatterEvent
{
s
cheme
:
string
;
s
elector
:
string
;
formatter
:
LabelRules
;
}
...
...
@@ -33,7 +33,7 @@ export interface ILabelService {
*/
getUriLabel
(
resource
:
URI
,
options
?:
{
relative
?:
boolean
,
noPrefix
?:
boolean
}):
string
;
getWorkspaceLabel
(
workspace
:
(
IWorkspaceIdentifier
|
ISingleFolderWorkspaceIdentifier
|
IWorkspace
),
options
?:
{
verbose
:
boolean
}):
string
;
registerFormatter
(
s
chema
:
string
,
formatter
:
LabelRules
):
IDisposable
;
registerFormatter
(
s
elector
:
string
,
formatter
:
LabelRules
):
IDisposable
;
onDidRegisterFormatter
:
Event
<
RegisterFormatterEvent
>
;
}
...
...
@@ -61,7 +61,7 @@ function hasDriveLetter(path: string): boolean {
export
class
LabelService
implements
ILabelService
{
_serviceBrand
:
any
;
private
readonly
formatters
=
new
Map
<
string
,
LabelRules
>
(
);
private
readonly
formatters
:
{
[
prefix
:
string
]:
LabelRules
}
=
Object
.
create
(
null
);
private
readonly
_onDidRegisterFormatter
=
new
Emitter
<
RegisterFormatterEvent
>
();
constructor
(
...
...
@@ -73,11 +73,25 @@ export class LabelService implements ILabelService {
return
this
.
_onDidRegisterFormatter
.
event
;
}
findFormatter
(
resource
:
URI
):
LabelRules
{
const
path
=
`
${
resource
.
scheme
}
://
${
resource
.
authority
}
`
;
let
bestPrefix
=
''
;
for
(
let
prefix
in
this
.
formatters
)
{
if
(
startsWith
(
path
,
prefix
)
&&
prefix
.
length
>
bestPrefix
.
length
)
{
bestPrefix
=
prefix
;
}
}
if
(
bestPrefix
.
length
)
{
return
this
.
formatters
[
bestPrefix
];
}
return
void
0
;
}
getUriLabel
(
resource
:
URI
,
options
:
{
relative
?:
boolean
,
noPrefix
?:
boolean
}
=
{}):
string
{
if
(
!
resource
)
{
return
undefined
;
}
const
formatter
=
this
.
f
ormatters
.
get
(
resource
.
schem
e
);
const
formatter
=
this
.
f
indFormatter
(
resourc
e
);
if
(
!
formatter
)
{
return
getPathLabel
(
resource
.
path
,
this
.
environmentService
,
options
.
relative
?
this
.
contextService
:
undefined
);
}
...
...
@@ -117,7 +131,7 @@ export class LabelService implements ILabelService {
// Workspace: Single Folder
if
(
isSingleFolderWorkspaceIdentifier
(
workspace
))
{
// Folder on disk
const
formatter
=
this
.
f
ormatters
.
get
(
workspace
.
schem
e
);
const
formatter
=
this
.
f
indFormatter
(
workspac
e
);
const
label
=
options
&&
options
.
verbose
?
this
.
getUriLabel
(
workspace
)
:
basenameOrAuthority
(
workspace
);
if
(
workspace
.
scheme
===
Schemas
.
file
)
{
return
label
;
...
...
@@ -142,12 +156,12 @@ export class LabelService implements ILabelService {
return
localize
(
'
workspaceName
'
,
"
{0} (Workspace)
"
,
workspaceName
);
}
registerFormatter
(
s
cheme
:
string
,
formatter
:
LabelRules
):
IDisposable
{
this
.
formatters
.
set
(
scheme
,
formatter
)
;
this
.
_onDidRegisterFormatter
.
fire
({
s
cheme
,
formatter
});
registerFormatter
(
s
elector
:
string
,
formatter
:
LabelRules
):
IDisposable
{
this
.
formatters
[
selector
]
=
formatter
;
this
.
_onDidRegisterFormatter
.
fire
({
s
elector
,
formatter
});
return
{
dispose
:
()
=>
this
.
formatters
.
delete
(
scheme
)
dispose
:
()
=>
delete
this
.
formatters
[
selector
]
};
}
...
...
src/vs/platform/label/test/label.test.ts
浏览文件 @
9ba00291
...
...
@@ -6,7 +6,6 @@
import
*
as
assert
from
'
assert
'
;
import
{
LabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
TestEnvironmentService
,
TestContextService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
TestWorkspace
}
from
'
vs/platform/workspace/test/common/testWorkspace
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
nativeSep
}
from
'
vs/base/common/paths
'
;
...
...
@@ -21,7 +20,7 @@ suite('URI Label', () => {
});
test
(
'
file scheme
'
,
function
()
{
labelService
.
registerFormatter
(
Schemas
.
file
,
{
labelService
.
registerFormatter
(
'
file://
'
,
{
uri
:
{
label
:
'
${path}
'
,
separator
:
nativeSep
,
...
...
@@ -39,7 +38,7 @@ suite('URI Label', () => {
});
test
(
'
custom scheme
'
,
function
()
{
labelService
.
registerFormatter
(
Schemas
.
vscode
,
{
labelService
.
registerFormatter
(
'
vscode://
'
,
{
uri
:
{
label
:
'
LABEL/${path}/${authority}/END
'
,
separator
:
'
/
'
,
...
...
src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts
浏览文件 @
9ba00291
...
...
@@ -40,8 +40,8 @@ export class MainThreadFileSystem implements MainThreadFileSystemShape {
this
.
_fileProvider
.
delete
(
handle
);
}
$setUriFormatter
(
s
cheme
:
string
,
formatter
:
LabelRules
):
void
{
this
.
_labelService
.
registerFormatter
(
s
cheme
,
formatter
);
$setUriFormatter
(
s
elector
:
string
,
formatter
:
LabelRules
):
void
{
this
.
_labelService
.
registerFormatter
(
s
elector
,
formatter
);
}
$onFileSystemChange
(
handle
:
number
,
changes
:
IFileChangeDto
[]):
void
{
...
...
src/vs/workbench/parts/files/electron-browser/files.contribution.ts
浏览文件 @
9ba00291
...
...
@@ -35,7 +35,6 @@ import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/group/common/editorGroupsService
'
;
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
nativeSep
}
from
'
vs/base/common/paths
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
...
...
@@ -58,7 +57,7 @@ export class OpenExplorerViewletAction extends ShowViewletAction {
class
FileUriLabelContribution
implements
IWorkbenchContribution
{
constructor
(@
ILabelService
labelService
:
ILabelService
)
{
labelService
.
registerFormatter
(
Schemas
.
file
,
{
labelService
.
registerFormatter
(
'
file://
'
,
{
uri
:
{
label
:
'
${authority}${path}
'
,
separator
:
nativeSep
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录