Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c8ffa51c
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,发现更多精彩内容 >>
提交
c8ffa51c
编写于
3月 11, 2019
作者:
P
Peng Lyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optional commenting range provider and empty comemnt thread factory.
上级
05efab0e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
47 addition
and
39 deletion
+47
-39
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+42
-12
src/vs/workbench/api/node/extHostComments.ts
src/vs/workbench/api/node/extHostComments.ts
+5
-27
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
c8ffa51c
...
...
@@ -736,7 +736,7 @@ declare module 'vscode' {
range
:
Range
;
/**
*
L
abel describing the [Comment Thread](#CommentThread)
*
The human-readable l
abel describing the [Comment Thread](#CommentThread)
*/
label
?:
string
;
...
...
@@ -746,19 +746,24 @@ declare module 'vscode' {
comments
:
Comment
[];
/**
* Optional accept input command
*
* `acceptInputCommand` is the default action rendered on Comment Widget, which is always placed rightmost.
*
It will be executed when users submit the comment from keyboard shortcut
.
* This
action is
disabled when the comment editor is empty.
*
This command will be invoked when users the user accepts the value in the comment editor
.
* This
command will
disabled when the comment editor is empty.
*/
acceptInputCommand
?:
Command
;
/**
* Optional additonal commands.
*
* `additionalCommands` are the secondary actions rendered on Comment Widget.
*/
additionalCommands
?:
Command
[];
/**
* Whether the thread should be collapsed or expanded when opening the document. Defaults to Collapsed.
* Whether the thread should be collapsed or expanded when opening the document.
* Defaults to Collapsed.
*/
collapsibleState
?:
CommentThreadCollapsibleState
;
dispose
?():
void
;
...
...
@@ -931,24 +936,49 @@ declare module 'vscode' {
value
:
string
;
}
export
interface
CommentingRangeProvider
{
provideCommentingRange
(
document
:
TextDocument
,
token
:
CancellationToken
):
ProviderResult
<
Range
[]
>
;
}
export
interface
EmptyCommentThreadFactory
{
/**
* The method `createEmptyCommentThread` is called when users attempt to create new comment thread from the gutter or command palette.
* Extensions still need to call `createCommentThread` inside this call when appropriate.
*/
createEmptyCommentThread
(
document
:
TextDocument
,
range
:
Range
):
ProviderResult
<
void
>
;
}
export
interface
CommentController
{
/**
* The id of this comment controller.
*/
readonly
id
:
string
;
/**
* The human-readable label of this comment controller.
*/
readonly
label
:
string
;
/**
* The active (focused)
comment input box
.
* The active (focused)
[comment input box](#CommentInputBox)
.
*/
readonly
inputBox
?:
CommentInputBox
;
createCommentThread
(
id
:
string
,
resource
:
Uri
,
range
:
Range
):
CommentThread
;
/**
* Optional commenting range provider.
* Provide a list [ranges](#Range) which support commenting to any given resource uri.
*
* @param uri The uri of the resource open in a text editor.
* @param callback, a handler called when users attempt to create a new comment thread, either from the gutter or command palette
* @param token A cancellation token.
* @return A thenable that resolves to a list of commenting ranges or null and undefined if the provider
* does not want to participate or was cancelled.
*/
registerCommentingRangeProvider
(
provider
:
(
document
:
TextDocument
,
token
:
CancellationToken
)
=>
ProviderResult
<
Range
[]
>
,
callback
:
(
document
:
TextDocument
,
range
:
Range
)
=>
void
):
void
;
commentingRangeProvider
?:
CommentingRangeProvider
;
/**
* Optional new comment thread factory.
*/
emptyCommentThreadFactory
:
EmptyCommentThreadFactory
;
/**
* Dispose this comment controller.
*/
dispose
():
void
;
}
...
...
src/vs/workbench/api/node/extHostComments.ts
浏览文件 @
c8ffa51c
...
...
@@ -108,19 +108,19 @@ export class ExtHostComments implements ExtHostCommentsShape {
const
document
=
this
.
_documents
.
getDocument
(
URI
.
revive
(
uriComponents
));
return
asPromise
(()
=>
{
return
commentController
.
commentingRangeProvider
.
provide
r
(
document
,
token
);
return
commentController
.
commentingRangeProvider
.
provide
CommentingRange
(
document
,
token
);
}).
then
(
ranges
=>
ranges
?
ranges
.
map
(
extHostTypeConverter
.
Range
.
from
)
:
undefined
);
}
$createNewCommentWidgetCallback
(
commentControllerHandle
:
number
,
uriComponents
:
UriComponents
,
range
:
IRange
,
token
:
CancellationToken
):
void
{
const
commentController
=
this
.
_commentControllers
.
get
(
commentControllerHandle
);
if
(
!
commentController
||
!
commentController
.
commentingRangeProvider
)
{
if
(
!
commentController
||
!
commentController
.
emptyCommentThreadFactory
)
{
return
;
}
const
document
=
this
.
_documents
.
getDocument
(
URI
.
revive
(
uriComponents
));
commentController
.
commentingRangeProvider
.
callback
(
document
,
extHostTypeConverter
.
Range
.
to
(
range
));
commentController
.
emptyCommentThreadFactory
.
createEmptyCommentThread
(
document
,
extHostTypeConverter
.
Range
.
to
(
range
));
}
registerWorkspaceCommentProvider
(
...
...
@@ -435,16 +435,6 @@ export class ExtHostCommentInputBox implements vscode.CommentInputBox {
this
.
_value
=
input
;
}
}
class
ExtHostCommentingRangeProvider
{
constructor
(
public
provider
:
(
document
:
vscode
.
TextDocument
,
token
:
vscode
.
CancellationToken
)
=>
vscode
.
ProviderResult
<
vscode
.
Range
[]
>
,
public
callback
:
(
document
:
vscode
.
TextDocument
,
range
:
vscode
.
Range
)
=>
void
)
{
}
}
class
ExtHostCommentController
implements
vscode
.
CommentController
{
get
id
():
string
{
return
this
.
_id
;
...
...
@@ -462,16 +452,8 @@ class ExtHostCommentController implements vscode.CommentController {
}
private
_threads
:
Map
<
number
,
ExtHostCommentThread
>
=
new
Map
<
number
,
ExtHostCommentThread
>
();
private
_commentingRangeProvider
:
ExtHostCommentingRangeProvider
|
undefined
=
undefined
;
get
commentingRangeProvider
():
ExtHostCommentingRangeProvider
|
undefined
{
return
this
.
_commentingRangeProvider
;
}
set
commentingRangeProvider
(
commentingRangeProvider
:
ExtHostCommentingRangeProvider
|
undefined
)
{
this
.
_commentingRangeProvider
=
commentingRangeProvider
;
}
commentingRangeProvider
?:
vscode
.
CommentingRangeProvider
;
emptyCommentThreadFactory
:
vscode
.
EmptyCommentThreadFactory
;
constructor
(
_extension
:
IExtensionDescription
,
...
...
@@ -490,10 +472,6 @@ class ExtHostCommentController implements vscode.CommentController {
return
commentThread
;
}
registerCommentingRangeProvider
(
provider
:
(
document
:
vscode
.
TextDocument
,
token
:
vscode
.
CancellationToken
)
=>
vscode
.
ProviderResult
<
vscode
.
Range
[]
>
,
callback
:
(
document
:
vscode
.
TextDocument
,
range
:
vscode
.
Range
)
=>
void
)
{
this
.
_commentingRangeProvider
=
new
ExtHostCommentingRangeProvider
(
provider
,
callback
);
}
$onCommentWidgetInputChange
(
input
:
string
)
{
if
(
!
this
.
inputBox
)
{
this
.
inputBox
=
new
ExtHostCommentInputBox
(
this
.
_proxy
,
this
.
handle
,
input
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录