Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
86cd46a4
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,发现更多精彩内容 >>
提交
86cd46a4
编写于
10月 26, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
deco - allow to derive new decoration from existing decoration, add IDecorationData#source
上级
f9d60296
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
53 addition
and
58 deletion
+53
-58
extensions/git/src/repository.ts
extensions/git/src/repository.ts
+1
-1
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+1
-0
src/vs/workbench/api/electron-browser/mainThreadDecorations.ts
...s/workbench/api/electron-browser/mainThreadDecorations.ts
+5
-4
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+2
-2
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+1
-1
src/vs/workbench/api/node/extHostDecorations.ts
src/vs/workbench/api/node/extHostDecorations.ts
+1
-1
src/vs/workbench/services/decorations/browser/decorations.ts
src/vs/workbench/services/decorations/browser/decorations.ts
+6
-5
src/vs/workbench/services/decorations/browser/decorationsService.ts
...kbench/services/decorations/browser/decorationsService.ts
+36
-41
src/vs/workbench/services/decorations/test/browser/decorationsService.test.ts
...vices/decorations/test/browser/decorationsService.test.ts
+0
-3
未找到文件。
extensions/git/src/repository.ts
浏览文件 @
86cd46a4
...
...
@@ -265,7 +265,7 @@ export class Resource implements SourceControlResourceState {
const
abbreviation
=
this
.
letter
;
const
color
=
this
.
color
;
const
priority
=
this
.
priority
;
return
{
bubble
:
true
,
title
,
abbreviation
,
color
,
priority
};
return
{
bubble
:
true
,
source
:
'
git.resource
'
,
title
,
abbreviation
,
color
,
priority
};
}
constructor
(
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
86cd46a4
...
...
@@ -178,6 +178,7 @@ declare module 'vscode' {
bubble
?:
boolean
;
abbreviation
?:
string
;
color
?:
ThemeColor
;
source
?:
string
;
}
export
interface
DecorationProvider
{
...
...
src/vs/workbench/api/electron-browser/mainThreadDecorations.ts
浏览文件 @
86cd46a4
...
...
@@ -29,23 +29,24 @@ export class MainThreadDecorations implements MainThreadDecorationsShape {
this
.
_provider
.
clear
();
}
$registerDecorationProvider
(
handle
:
number
):
void
{
$registerDecorationProvider
(
handle
:
number
,
label
:
string
):
void
{
let
emitter
=
new
Emitter
<
URI
[]
>
();
let
registration
=
this
.
_decorationsService
.
registerDecorationsProvider
({
label
:
'
extension-provider
'
,
label
,
onDidChange
:
emitter
.
event
,
provideDecorations
:
(
uri
)
=>
{
return
this
.
_proxy
.
$providerDecorations
(
handle
,
uri
).
then
(
data
=>
{
if
(
!
data
)
{
return
undefined
;
}
const
[
weight
,
bubble
,
title
,
letter
,
themeColor
]
=
data
;
const
[
weight
,
bubble
,
title
,
letter
,
themeColor
,
source
]
=
data
;
return
{
weight
:
weight
||
0
,
bubble
:
bubble
||
false
,
color
:
themeColor
&&
themeColor
.
id
,
title
,
letter
,
color
:
themeColor
&&
themeColor
.
id
source
,
};
});
}
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
86cd46a4
...
...
@@ -378,8 +378,8 @@ export function createApiFactory(
sampleFunction
:
proposedApiFunction
(
extension
,
()
=>
{
return
extHostMessageService
.
showMessage
(
extension
,
Severity
.
Info
,
'
Hello Proposed Api!
'
,
{},
[]);
}),
registerDecorationProvider
:
proposedApiFunction
(
extension
,
(
provider
:
vscode
.
DecorationProvider
)
=>
{
return
extHostDecorations
.
registerDecorationProvider
(
provider
,
extension
.
id
);
registerDecorationProvider
:
proposedApiFunction
(
extension
,
(
provider
:
vscode
.
DecorationProvider
,
source
)
=>
{
return
extHostDecorations
.
registerDecorationProvider
(
provider
,
source
);
})
};
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
86cd46a4
...
...
@@ -625,7 +625,7 @@ export interface ExtHostDebugServiceShape {
}
export
type
DecorationData
=
[
number
,
boolean
,
string
,
string
,
ThemeColor
];
export
type
DecorationData
=
[
number
,
boolean
,
string
,
string
,
ThemeColor
,
string
];
export
interface
ExtHostDecorationsShape
{
$providerDecorations
(
handle
:
number
,
uri
:
URI
):
TPromise
<
DecorationData
>
;
...
...
src/vs/workbench/api/node/extHostDecorations.ts
浏览文件 @
86cd46a4
...
...
@@ -41,7 +41,7 @@ export class ExtHostDecorations implements ExtHostDecorationsShape {
$providerDecorations
(
handle
:
number
,
uri
:
URI
):
TPromise
<
DecorationData
>
{
const
provider
=
this
.
_provider
.
get
(
handle
);
return
asWinJsPromise
(
token
=>
provider
.
provideDecoration
(
uri
,
token
)).
then
(
data
=>
{
return
data
&&
<
DecorationData
>
[
data
.
priority
,
data
.
bubble
,
data
.
title
,
data
.
abbreviation
,
data
.
color
];
return
data
&&
<
DecorationData
>
[
data
.
priority
,
data
.
bubble
,
data
.
title
,
data
.
abbreviation
,
data
.
color
,
data
.
source
];
});
}
}
src/vs/workbench/services/decorations/browser/decorations.ts
浏览文件 @
86cd46a4
...
...
@@ -18,14 +18,15 @@ export interface IDecorationData {
readonly
letter
?:
string
;
readonly
title
?:
string
;
readonly
bubble
?:
boolean
;
readonly
source
?:
string
;
}
export
interface
IDecoration
{
readonly
_decoBrand
:
undefined
;
readonly
weight
?:
number
;
readonly
title
?
:
string
;
readonly
labelClassName
?:
string
;
readonly
badgeClassName
?:
string
;
readonly
title
:
string
;
readonly
labelClassName
:
string
;
readonly
badgeClassName
:
string
;
readonly
data
:
IDecorationData
[]
;
update
(
replace
:
{
source
?:
string
,
data
?:
IDecorationData
}):
IDecoration
;
}
export
interface
IDecorationsProvider
{
...
...
src/vs/workbench/services/decorations/browser/decorationsService.ts
浏览文件 @
86cd46a4
...
...
@@ -75,33 +75,6 @@ class DecorationRule {
}
}
class
ResourceDecoration
implements
IDecoration
{
static
from
(
data
:
IDecorationData
|
IDecorationData
[]):
ResourceDecoration
{
let
result
=
new
ResourceDecoration
(
data
);
if
(
Array
.
isArray
(
data
))
{
result
.
weight
=
data
[
0
].
weight
;
result
.
title
=
data
.
map
(
d
=>
d
.
title
).
join
(
'
,
'
);
}
else
{
result
.
weight
=
data
.
weight
;
result
.
title
=
data
.
title
;
}
return
result
;
}
_decoBrand
:
undefined
;
_data
:
IDecorationData
|
IDecorationData
[];
weight
?:
number
;
title
?:
string
;
labelClassName
?:
string
;
badgeClassName
?:
string
;
private
constructor
(
data
:
IDecorationData
|
IDecorationData
[])
{
this
.
_data
=
data
;
}
}
class
DecorationStyles
{
private
readonly
_disposables
:
IDisposable
[];
...
...
@@ -121,10 +94,13 @@ class DecorationStyles {
this
.
_styleElement
.
parentElement
.
removeChild
(
this
.
_styleElement
);
}
asDecoration
(
data
:
IDecorationData
|
IDecorationData
[]):
ResourceDecoration
{
asDecoration
(
data
:
IDecorationData
[],
onlyChildren
:
boolean
):
IDecoration
{
// sort by weight
data
.
sort
((
a
,
b
)
=>
b
.
weight
-
a
.
weight
);
let
key
=
DecorationRule
.
keyOf
(
data
);
let
rule
=
this
.
_decorationRules
.
get
(
key
);
let
result
=
ResourceDecoration
.
from
(
data
);
if
(
!
rule
)
{
// new css rule
...
...
@@ -133,9 +109,35 @@ class DecorationStyles {
rule
.
appendCSSRules
(
this
.
_styleElement
,
this
.
_themeService
.
getTheme
());
}
result
.
labelClassName
=
rule
.
labelClassName
;
result
.
badgeClassName
=
rule
.
badgeClassName
;
return
result
;
return
{
data
,
labelClassName
:
rule
.
labelClassName
,
badgeClassName
:
!
onlyChildren
?
rule
.
badgeClassName
:
''
,
title
:
!
onlyChildren
?
data
.
filter
(
d
=>
Boolean
(
d
.
title
)).
map
(
d
=>
d
.
title
).
join
(
'
,
'
)
:
''
,
update
:
replace
=>
{
let
newData
=
data
.
slice
();
if
(
!
replace
.
source
)
{
// add -> just append
newData
.
push
(
replace
.
data
);
}
else
{
// remove/replace -> require a walk
for
(
let
i
=
0
;
i
<
newData
.
length
;
i
++
)
{
if
(
newData
[
i
].
source
===
replace
.
source
)
{
if
(
!
replace
.
data
)
{
// remove
newData
.
splice
(
i
,
1
);
i
--
;
}
else
{
// replace
newData
[
i
]
=
replace
.
data
;
}
}
}
}
return
this
.
asDecoration
(
newData
,
onlyChildren
);
}
};
}
private
_onThemeChange
():
void
{
...
...
@@ -373,15 +375,8 @@ export class FileDecorationsService implements IDecorationsService {
if
(
data
.
length
===
0
)
{
return
undefined
;
}
else
if
(
onlyChildren
)
{
let
result
=
this
.
_decorationStyles
.
asDecoration
(
data
.
sort
((
a
,
b
)
=>
b
.
weight
-
a
.
weight
)[
0
]);
result
.
badgeClassName
=
''
;
result
.
title
=
''
;
return
result
;
}
else
if
(
data
.
length
===
1
)
{
return
this
.
_decorationStyles
.
asDecoration
(
data
[
0
]);
}
else
{
return
this
.
_decorationStyles
.
asDecoration
(
data
.
sort
((
a
,
b
)
=>
b
.
weight
-
a
.
weight
));
}
return
this
.
_decorationStyles
.
asDecoration
(
data
,
onlyChildren
);
}
}
src/vs/workbench/services/decorations/test/browser/decorationsService.test.ts
浏览文件 @
86cd46a4
...
...
@@ -120,7 +120,6 @@ suite('DecorationsService', function () {
let
deco
=
service
.
getDecoration
(
childUri
,
false
);
assert
.
equal
(
deco
.
title
,
'
.txt
'
);
assert
.
equal
(
deco
.
weight
,
17
);
deco
=
service
.
getDecoration
(
childUri
.
with
({
path
:
'
some/path/
'
}),
true
);
assert
.
equal
(
deco
,
undefined
);
...
...
@@ -139,10 +138,8 @@ suite('DecorationsService', function () {
deco
=
service
.
getDecoration
(
childUri
,
false
);
assert
.
equal
(
deco
.
title
,
'
.txt.bubble
'
);
assert
.
equal
(
deco
.
weight
,
71
);
deco
=
service
.
getDecoration
(
childUri
.
with
({
path
:
'
some/path/
'
}),
true
);
assert
.
equal
(
deco
.
title
,
''
);
assert
.
equal
(
deco
.
weight
,
71
);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录