Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8932f62a
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,发现更多精彩内容 >>
提交
8932f62a
编写于
9月 25, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adress API feedback
https://github.com/microsoft/vscode/issues/54938
上级
b67b5e8e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
65 addition
and
64 deletion
+65
-64
extensions/git/src/decorationProvider.ts
extensions/git/src/decorationProvider.ts
+18
-18
extensions/git/src/repository.ts
extensions/git/src/repository.ts
+5
-5
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+14
-20
src/vs/workbench/api/common/extHost.api.impl.ts
src/vs/workbench/api/common/extHost.api.impl.ts
+2
-2
src/vs/workbench/api/common/extHostDecorations.ts
src/vs/workbench/api/common/extHostDecorations.ts
+7
-7
src/vs/workbench/api/common/extHostTypes.ts
src/vs/workbench/api/common/extHostTypes.ts
+14
-7
src/vs/workbench/test/browser/api/extHostDecorations.test.ts
src/vs/workbench/test/browser/api/extHostDecorations.test.ts
+5
-5
未找到文件。
extensions/git/src/decorationProvider.ts
浏览文件 @
8932f62a
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
window
,
workspace
,
Uri
,
Disposable
,
Event
,
EventEmitter
,
Decoration
,
DecorationProvider
,
ThemeColor
}
from
'
vscode
'
;
import
{
window
,
workspace
,
Uri
,
Disposable
,
Event
,
EventEmitter
,
FileDecoration
,
File
DecorationProvider
,
ThemeColor
}
from
'
vscode
'
;
import
*
as
path
from
'
path
'
;
import
{
Repository
,
GitResourceGroup
}
from
'
./repository
'
;
import
{
Model
}
from
'
./model
'
;
...
...
@@ -11,16 +11,16 @@ import { debounce } from './decorators';
import
{
filterEvent
,
dispose
,
anyEvent
,
fireEvent
,
PromiseSource
}
from
'
./util
'
;
import
{
GitErrorCodes
,
Status
}
from
'
./api/git
'
;
class
GitIgnoreDecorationProvider
implements
DecorationProvider
{
class
GitIgnoreDecorationProvider
implements
File
DecorationProvider
{
private
static
Decoration
:
Decoration
=
{
priority
:
3
,
color
:
new
ThemeColor
(
'
gitDecoration.ignoredResourceForeground
'
)
};
private
static
Decoration
:
File
Decoration
=
{
priority
:
3
,
color
:
new
ThemeColor
(
'
gitDecoration.ignoredResourceForeground
'
)
};
readonly
onDidChange
Decorations
:
Event
<
Uri
[]
>
;
private
queue
=
new
Map
<
string
,
{
repository
:
Repository
;
queue
:
Map
<
string
,
PromiseSource
<
Decoration
|
undefined
>>
;
}
>
();
readonly
onDidChange
:
Event
<
Uri
[]
>
;
private
queue
=
new
Map
<
string
,
{
repository
:
Repository
;
queue
:
Map
<
string
,
PromiseSource
<
File
Decoration
|
undefined
>>
;
}
>
();
private
disposables
:
Disposable
[]
=
[];
constructor
(
private
model
:
Model
)
{
this
.
onDidChange
Decorations
=
fireEvent
(
anyEvent
<
any
>
(
this
.
onDidChange
=
fireEvent
(
anyEvent
<
any
>
(
filterEvent
(
workspace
.
onDidSaveTextDocument
,
e
=>
/
\.
gitignore$|
\.
git
\/
info
\/
exclude$/
.
test
(
e
.
uri
.
path
)),
model
.
onDidOpenRepository
,
model
.
onDidCloseRepository
...
...
@@ -29,7 +29,7 @@ class GitIgnoreDecorationProvider implements DecorationProvider {
this
.
disposables
.
push
(
window
.
registerDecorationProvider
(
this
));
}
async
provide
Decoration
(
uri
:
Uri
):
Promise
<
Decoration
|
undefined
>
{
async
provide
FileDecoration
(
uri
:
Uri
):
Promise
<
File
Decoration
|
undefined
>
{
const
repository
=
this
.
model
.
getRepository
(
uri
);
if
(
!
repository
)
{
...
...
@@ -39,7 +39,7 @@ class GitIgnoreDecorationProvider implements DecorationProvider {
let
queueItem
=
this
.
queue
.
get
(
repository
.
root
);
if
(
!
queueItem
)
{
queueItem
=
{
repository
,
queue
:
new
Map
<
string
,
PromiseSource
<
Decoration
|
undefined
>>
()
};
queueItem
=
{
repository
,
queue
:
new
Map
<
string
,
PromiseSource
<
File
Decoration
|
undefined
>>
()
};
this
.
queue
.
set
(
repository
.
root
,
queueItem
);
}
...
...
@@ -84,19 +84,19 @@ class GitIgnoreDecorationProvider implements DecorationProvider {
}
}
class
GitDecorationProvider
implements
DecorationProvider
{
class
GitDecorationProvider
implements
File
DecorationProvider
{
private
static
SubmoduleDecorationData
:
Decoration
=
{
t
itle
:
'
Submodule
'
,
letter
:
'
S
'
,
private
static
SubmoduleDecorationData
:
File
Decoration
=
{
t
ooltip
:
'
Submodule
'
,
badge
:
'
S
'
,
color
:
new
ThemeColor
(
'
gitDecoration.submoduleResourceForeground
'
)
};
private
readonly
_onDidChangeDecorations
=
new
EventEmitter
<
Uri
[]
>
();
readonly
onDidChange
Decorations
:
Event
<
Uri
[]
>
=
this
.
_onDidChangeDecorations
.
event
;
readonly
onDidChange
:
Event
<
Uri
[]
>
=
this
.
_onDidChangeDecorations
.
event
;
private
disposables
:
Disposable
[]
=
[];
private
decorations
=
new
Map
<
string
,
Decoration
>
();
private
decorations
=
new
Map
<
string
,
File
Decoration
>
();
constructor
(
private
repository
:
Repository
)
{
this
.
disposables
.
push
(
...
...
@@ -106,7 +106,7 @@ class GitDecorationProvider implements DecorationProvider {
}
private
onDidRunGitStatus
():
void
{
let
newDecorations
=
new
Map
<
string
,
Decoration
>
();
let
newDecorations
=
new
Map
<
string
,
File
Decoration
>
();
this
.
collectSubmoduleDecorationData
(
newDecorations
);
this
.
collectDecorationData
(
this
.
repository
.
indexGroup
,
newDecorations
);
...
...
@@ -119,7 +119,7 @@ class GitDecorationProvider implements DecorationProvider {
this
.
_onDidChangeDecorations
.
fire
([...
uris
.
values
()].
map
(
value
=>
Uri
.
parse
(
value
,
true
)));
}
private
collectDecorationData
(
group
:
GitResourceGroup
,
bucket
:
Map
<
string
,
Decoration
>
):
void
{
private
collectDecorationData
(
group
:
GitResourceGroup
,
bucket
:
Map
<
string
,
File
Decoration
>
):
void
{
for
(
const
r
of
group
.
resourceStates
)
{
const
decoration
=
r
.
resourceDecoration
;
...
...
@@ -134,13 +134,13 @@ class GitDecorationProvider implements DecorationProvider {
}
}
private
collectSubmoduleDecorationData
(
bucket
:
Map
<
string
,
Decoration
>
):
void
{
private
collectSubmoduleDecorationData
(
bucket
:
Map
<
string
,
File
Decoration
>
):
void
{
for
(
const
submodule
of
this
.
repository
.
submodules
)
{
bucket
.
set
(
Uri
.
file
(
path
.
join
(
this
.
repository
.
root
,
submodule
.
path
)).
toString
(),
GitDecorationProvider
.
SubmoduleDecorationData
);
}
}
provide
Decoration
(
uri
:
Uri
):
Decoration
|
undefined
{
provide
FileDecoration
(
uri
:
Uri
):
File
Decoration
|
undefined
{
return
this
.
decorations
.
get
(
uri
.
toString
());
}
...
...
extensions/git/src/repository.ts
浏览文件 @
8932f62a
...
...
@@ -5,7 +5,7 @@
import
*
as
fs
from
'
fs
'
;
import
*
as
path
from
'
path
'
;
import
{
CancellationToken
,
Command
,
Disposable
,
Event
,
EventEmitter
,
Memento
,
OutputChannel
,
ProgressLocation
,
ProgressOptions
,
scm
,
SourceControl
,
SourceControlInputBox
,
SourceControlInputBoxValidation
,
SourceControlInputBoxValidationType
,
SourceControlResourceDecorations
,
SourceControlResourceGroup
,
SourceControlResourceState
,
ThemeColor
,
Uri
,
window
,
workspace
,
WorkspaceEdit
,
Decoration
}
from
'
vscode
'
;
import
{
CancellationToken
,
Command
,
Disposable
,
Event
,
EventEmitter
,
Memento
,
OutputChannel
,
ProgressLocation
,
ProgressOptions
,
scm
,
SourceControl
,
SourceControlInputBox
,
SourceControlInputBoxValidation
,
SourceControlInputBoxValidationType
,
SourceControlResourceDecorations
,
SourceControlResourceGroup
,
SourceControlResourceState
,
ThemeColor
,
Uri
,
window
,
workspace
,
WorkspaceEdit
,
File
Decoration
}
from
'
vscode
'
;
import
*
as
nls
from
'
vscode-nls
'
;
import
{
Branch
,
Change
,
GitErrorCodes
,
LogOptions
,
Ref
,
RefType
,
Remote
,
Status
,
CommitOptions
,
BranchQuery
}
from
'
./api/git
'
;
import
{
AutoFetcher
}
from
'
./autofetch
'
;
...
...
@@ -253,11 +253,11 @@ export class Resource implements SourceControlResourceState {
}
}
get
resourceDecoration
():
Decoration
{
get
resourceDecoration
():
File
Decoration
{
return
{
bubbl
e
:
this
.
type
!==
Status
.
DELETED
&&
this
.
type
!==
Status
.
INDEX_DELETED
,
t
itle
:
this
.
tooltip
,
letter
:
this
.
letter
,
propagt
e
:
this
.
type
!==
Status
.
DELETED
&&
this
.
type
!==
Status
.
INDEX_DELETED
,
t
ooltip
:
this
.
tooltip
,
badge
:
this
.
letter
,
color
:
this
.
color
,
priority
:
this
.
priority
};
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
8932f62a
...
...
@@ -717,23 +717,18 @@ declare module 'vscode' {
//#region file-decorations: https://github.com/microsoft/vscode/issues/54938
// TODO@jrieken FileDecoration, FileDecorationProvider etc.
// TODO@jrieken Add selector notion to limit decorations to a view.
// TODO@jrieken Rename `Decoration.letter` to `short` so that it could be used for coverage et al.
// TODO@jrieken priority -> DecorationSeverity.INFO,WARN,ERROR
// TODO@jrieken title -> tooltip
// TODO@jrieken bubble -> propagte
export
class
Decoration
{
export
class
FileDecoration
{
/**
* A
letter
that represents this decoration.
* A
very short string
that represents this decoration.
*/
letter
?:
string
;
badge
?:
string
;
/**
*
The human-readable title
for this decoration.
*
A human-readable tooltip
for this decoration.
*/
t
itle
?:
string
;
t
ooltip
?:
string
;
/**
* The color of this decoration.
...
...
@@ -747,46 +742,45 @@ declare module 'vscode' {
/**
* A flag expressing that this decoration should be
* propagted to its parents.
* propag
a
ted to its parents.
*/
bubbl
e
?:
boolean
;
propagt
e
?:
boolean
;
/**
* Creates a new decoration.
*
* @param
letter
A letter that represents the decoration.
* @param t
itle The title
of the decoration.
* @param
badge
A letter that represents the decoration.
* @param t
ooltip The tooltip
of the decoration.
* @param color The color of the decoration.
*/
constructor
(
letter
?:
string
,
title
?:
string
,
color
?:
ThemeColor
);
constructor
(
badge
?:
string
,
tooltip
?:
string
,
color
?:
ThemeColor
);
}
/**
* The decoration provider interfaces defines the contract between extensions and
* file decorations.
*/
export
interface
DecorationProvider
{
export
interface
File
DecorationProvider
{
/**
* An event to signal decorations for one or many files have changed.
*
* @see [EventEmitter](#EventEmitter
*/
onDidChange
Decorations
:
Event
<
undefined
|
Uri
|
Uri
[]
>
;
onDidChange
:
Event
<
undefined
|
Uri
|
Uri
[]
>
;
/**
* Provide decorations for a given uri.
*
*
* @param uri The uri of the file to provide a decoration for.
* @param token A cancellation token.
* @returns A decoration or a thenable that resolves to such.
*/
provide
Decoration
(
uri
:
Uri
,
token
:
CancellationToken
):
ProviderResult
<
Decoration
>
;
provide
FileDecoration
(
uri
:
Uri
,
token
:
CancellationToken
):
ProviderResult
<
File
Decoration
>
;
}
export
namespace
window
{
export
function
registerDecorationProvider
(
provider
:
DecorationProvider
):
Disposable
;
export
function
registerDecorationProvider
(
provider
:
File
DecorationProvider
):
Disposable
;
}
//#endregion
...
...
src/vs/workbench/api/common/extHost.api.impl.ts
浏览文件 @
8932f62a
...
...
@@ -605,7 +605,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
registerCustomEditorProvider
:
(
viewType
:
string
,
provider
:
vscode
.
CustomTextEditorProvider
|
vscode
.
CustomReadonlyEditorProvider
,
options
:
{
webviewOptions
?:
vscode
.
WebviewPanelOptions
,
supportsMultipleEditorsPerDocument
?:
boolean
}
=
{})
=>
{
return
extHostCustomEditors
.
registerCustomEditorProvider
(
extension
,
viewType
,
provider
,
options
);
},
registerDecorationProvider
(
provider
:
vscode
.
DecorationProvider
)
{
registerDecorationProvider
(
provider
:
vscode
.
File
DecorationProvider
)
{
checkProposedApiEnabled
(
extension
);
return
extHostDecorations
.
registerDecorationProvider
(
provider
,
extension
.
identifier
);
},
...
...
@@ -1138,7 +1138,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
CallHierarchyItem
:
extHostTypes
.
CallHierarchyItem
,
DebugConsoleMode
:
extHostTypes
.
DebugConsoleMode
,
DebugConfigurationProviderTriggerKind
:
extHostTypes
.
DebugConfigurationProviderTriggerKind
,
Decoration
:
extHostTypes
.
Decoration
,
FileDecoration
:
extHostTypes
.
File
Decoration
,
UIKind
:
UIKind
,
ColorThemeKind
:
extHostTypes
.
ColorThemeKind
,
TimelineItem
:
extHostTypes
.
TimelineItem
,
...
...
src/vs/workbench/api/common/extHostDecorations.ts
浏览文件 @
8932f62a
...
...
@@ -6,7 +6,7 @@
import
type
*
as
vscode
from
'
vscode
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
MainContext
,
ExtHostDecorationsShape
,
MainThreadDecorationsShape
,
DecorationData
,
DecorationRequest
,
DecorationReply
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
Disposable
,
Decoration
}
from
'
vs/workbench/api/common/extHostTypes
'
;
import
{
Disposable
,
File
Decoration
}
from
'
vs/workbench/api/common/extHostTypes
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
ExtensionIdentifier
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -15,7 +15,7 @@ import { ILogService } from 'vs/platform/log/common/log';
import
{
asArray
}
from
'
vs/base/common/arrays
'
;
interface
ProviderData
{
provider
:
vscode
.
DecorationProvider
;
provider
:
vscode
.
File
DecorationProvider
;
extensionId
:
ExtensionIdentifier
;
}
...
...
@@ -34,12 +34,12 @@ export class ExtHostDecorations implements ExtHostDecorationsShape {
this
.
_proxy
=
extHostRpc
.
getProxy
(
MainContext
.
MainThreadDecorations
);
}
registerDecorationProvider
(
provider
:
vscode
.
DecorationProvider
,
extensionId
:
ExtensionIdentifier
):
vscode
.
Disposable
{
registerDecorationProvider
(
provider
:
vscode
.
File
DecorationProvider
,
extensionId
:
ExtensionIdentifier
):
vscode
.
Disposable
{
const
handle
=
ExtHostDecorations
.
_handlePool
++
;
this
.
_provider
.
set
(
handle
,
{
provider
,
extensionId
});
this
.
_proxy
.
$registerDecorationProvider
(
handle
,
extensionId
.
value
);
const
listener
=
provider
.
onDidChange
Decorations
(
e
=>
{
const
listener
=
provider
.
onDidChange
(
e
=>
{
this
.
_proxy
.
$onDidChange
(
handle
,
!
e
||
(
Array
.
isArray
(
e
)
&&
e
.
length
>
250
)
?
null
:
asArray
(
e
));
...
...
@@ -65,13 +65,13 @@ export class ExtHostDecorations implements ExtHostDecorationsShape {
await
Promise
.
all
(
requests
.
map
(
async
request
=>
{
try
{
const
{
uri
,
id
}
=
request
;
const
data
=
await
Promise
.
resolve
(
provider
.
provideDecoration
(
URI
.
revive
(
uri
),
token
));
const
data
=
await
Promise
.
resolve
(
provider
.
provide
File
Decoration
(
URI
.
revive
(
uri
),
token
));
if
(
!
data
)
{
return
;
}
try
{
Decoration
.
validate
(
data
);
result
[
id
]
=
<
DecorationData
>
[
data
.
priority
,
data
.
bubble
,
data
.
title
,
data
.
letter
,
data
.
color
];
File
Decoration
.
validate
(
data
);
result
[
id
]
=
<
DecorationData
>
[
data
.
priority
,
data
.
propagte
,
data
.
tooltip
,
data
.
badge
,
data
.
color
];
}
catch
(
e
)
{
this
.
_logService
.
warn
(
`INVALID decoration from extension '
${
extensionId
.
value
}
':
${
e
}
`
);
}
...
...
src/vs/workbench/api/common/extHostTypes.ts
浏览文件 @
8932f62a
...
...
@@ -2729,22 +2729,29 @@ export enum ExtensionKind {
Workspace
=
2
}
export
class
Decoration
{
export
class
File
Decoration
{
static
validate
(
d
:
Decoration
):
void
{
if
(
d
.
letter
&&
d
.
letter
.
length
!==
1
)
{
static
validate
(
d
:
File
Decoration
):
void
{
if
(
d
.
badge
&&
d
.
badge
.
length
!==
1
)
{
throw
new
Error
(
`The 'letter'-property must be undefined or a single character`
);
}
if
(
!
d
.
bubble
&&
!
d
.
color
&&
!
d
.
letter
&&
!
d
.
priority
&&
!
d
.
title
)
{
if
(
!
d
.
color
&&
!
d
.
badge
&&
!
d
.
tooltip
)
{
throw
new
Error
(
`The decoration is empty`
);
}
}
letter
?:
string
;
t
itle
?:
string
;
badge
?:
string
;
t
ooltip
?:
string
;
color
?:
vscode
.
ThemeColor
;
priority
?:
number
;
bubble
?:
boolean
;
propagate
?:
boolean
;
constructor
(
badge
?:
string
,
tooltip
?:
string
,
color
?:
ThemeColor
)
{
this
.
badge
=
badge
;
this
.
tooltip
=
tooltip
;
this
.
color
=
color
;
}
}
//#region Theming
...
...
src/vs/workbench/test/browser/api/extHostDecorations.test.ts
浏览文件 @
8932f62a
...
...
@@ -48,8 +48,8 @@ suite('ExtHostDecorations', function () {
// never returns
extHostDecorations
.
registerDecorationProvider
({
onDidChange
Decorations
:
Event
.
None
,
provideDecoration
()
{
onDidChange
:
Event
.
None
,
provide
File
Decoration
()
{
calledA
=
true
;
return
new
Promise
(()
=>
{
});
}
...
...
@@ -57,10 +57,10 @@ suite('ExtHostDecorations', function () {
// always returns
extHostDecorations
.
registerDecorationProvider
({
onDidChange
Decorations
:
Event
.
None
,
provideDecoration
()
{
onDidChange
:
Event
.
None
,
provide
File
Decoration
()
{
calledB
=
true
;
return
new
Promise
(
resolve
=>
resolve
({
letter
:
'
H
'
,
title
:
'
Hello
'
}));
return
new
Promise
(
resolve
=>
resolve
({
badge
:
'
H
'
,
tooltip
:
'
Hello
'
}));
}
},
nullExtensionDescription
.
identifier
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录