Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
905248fa
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,发现更多精彩内容 >>
提交
905248fa
编写于
3月 06, 2019
作者:
P
Peng Lyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
comments panel handle new comment thread registration.
上级
42194d82
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
47 addition
and
10 deletion
+47
-10
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+1
-1
src/vs/workbench/api/electron-browser/mainThreadComments.ts
src/vs/workbench/api/electron-browser/mainThreadComments.ts
+29
-0
src/vs/workbench/api/node/extHostComments.ts
src/vs/workbench/api/node/extHostComments.ts
+8
-6
src/vs/workbench/contrib/comments/common/commentModel.ts
src/vs/workbench/contrib/comments/common/commentModel.ts
+9
-3
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
905248fa
...
...
@@ -992,7 +992,7 @@ declare module 'vscode' {
* @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
:
(
uri
:
Uri
,
token
:
CancellationToken
)
=>
ProviderResult
<
Range
[]
>
,
callback
:
(
uri
:
Uri
,
range
:
Range
)
=>
void
);
registerCommentingRangeProvider
(
provider
:
(
document
:
TextDocument
,
token
:
CancellationToken
)
=>
ProviderResult
<
Range
[]
>
,
callback
:
(
document
:
TextDocument
,
range
:
Range
)
=>
void
);
dispose
():
void
;
}
...
...
src/vs/workbench/api/electron-browser/mainThreadComments.ts
浏览文件 @
905248fa
...
...
@@ -239,6 +239,13 @@ export class MainThreadCommentController {
updateComments
(
commentThreadHandle
:
number
,
comments
:
modes
.
Comment
[])
{
let
thread
=
this
.
_threads
.
get
(
commentThreadHandle
);
thread
.
comments
=
comments
;
this
.
_commentService
.
updateComments
(
`
${
this
.
handle
}
`
,
{
added
:
[],
removed
:
[],
changed
:
[
thread
],
draftMode
:
modes
.
DraftMode
.
NotSupported
});
}
updateAcceptInputCommands
(
commentThreadHandle
:
number
,
acceptInputCommands
:
modes
.
Command
[])
{
...
...
@@ -289,6 +296,15 @@ export class MainThreadCommentController {
};
}
getAllComments
():
MainThreadCommentThread
[]
{
let
ret
=
[];
for
(
let
thread
of
keys
(
this
.
_threads
))
{
ret
.
push
(
this
.
_threads
.
get
(
thread
));
}
return
ret
;
}
toJSON
():
any
{
return
{
$mid
:
6
,
...
...
@@ -348,9 +364,13 @@ export class MainThreadComments extends Disposable implements MainThreadComments
this
.
_commentService
.
registerCommentController
(
String
(
handle
),
provider
);
this
.
_commentControllers
.
set
(
handle
,
provider
);
const
providerId
=
generateUuid
();
this
.
_handlers
.
set
(
handle
,
providerId
);
const
commentsPanelAlreadyConstructed
=
this
.
_panelService
.
getPanels
().
some
(
panel
=>
panel
.
id
===
COMMENTS_PANEL_ID
);
if
(
!
commentsPanelAlreadyConstructed
)
{
this
.
registerPanel
(
commentsPanelAlreadyConstructed
);
this
.
registerOpenPanelListener
(
commentsPanelAlreadyConstructed
);
}
this
.
_commentService
.
setWorkspaceComments
(
String
(
handle
),
[]);
}
...
...
@@ -466,6 +486,15 @@ export class MainThreadComments extends Disposable implements MainThreadComments
});
});
keys
(
this
.
_commentControllers
).
forEach
(
handle
=>
{
let
threads
=
this
.
_commentControllers
.
get
(
handle
).
getAllComments
();
if
(
threads
.
length
)
{
const
providerId
=
this
.
_handlers
.
get
(
handle
);
this
.
_commentService
.
setWorkspaceComments
(
providerId
,
threads
);
}
});
if
(
this
.
_openPanelListener
)
{
this
.
_openPanelListener
.
dispose
();
this
.
_openPanelListener
=
null
;
...
...
src/vs/workbench/api/node/extHostComments.ts
浏览文件 @
905248fa
...
...
@@ -106,9 +106,10 @@ export class ExtHostComments implements ExtHostCommentsShape {
return
Promise
.
resolve
(
undefined
);
}
const
document
=
this
.
_documents
.
getDocument
(
URI
.
revive
(
uriComponents
));
return
asPromise
(()
=>
{
return
commentController
.
commentingRangeProvider
.
provider
(
URI
.
revive
(
uriComponents
)
,
token
);
}).
then
(
ranges
=>
ranges
.
map
(
extHostTypeConverter
.
Range
.
from
)
);
return
commentController
.
commentingRangeProvider
.
provider
(
document
,
token
);
}).
then
(
ranges
=>
ranges
?
ranges
.
map
(
extHostTypeConverter
.
Range
.
from
)
:
undefined
);
}
$createNewCommentWidgetCallback
(
commentControllerHandle
:
number
,
uriComponents
:
UriComponents
,
range
:
IRange
,
token
:
CancellationToken
):
void
{
...
...
@@ -118,7 +119,8 @@ export class ExtHostComments implements ExtHostCommentsShape {
return
;
}
commentController
.
commentingRangeProvider
.
callback
(
URI
.
revive
(
uriComponents
),
extHostTypeConverter
.
Range
.
to
(
range
));
const
document
=
this
.
_documents
.
getDocument
(
URI
.
revive
(
uriComponents
));
commentController
.
commentingRangeProvider
.
callback
(
document
,
extHostTypeConverter
.
Range
.
to
(
range
));
}
registerWorkspaceCommentProvider
(
...
...
@@ -412,8 +414,8 @@ export class ExtHostCommentInputBox implements vscode.CommentInputBox {
class
ExtHostCommentingRangeProvider
{
constructor
(
public
provider
:
(
uri
:
vscode
.
Uri
,
token
:
vscode
.
CancellationToken
)
=>
vscode
.
ProviderResult
<
vscode
.
Range
[]
>
,
public
callback
:
(
uri
:
vscode
.
Uri
,
range
:
vscode
.
Range
)
=>
void
public
provider
:
(
document
:
vscode
.
TextDocument
,
token
:
vscode
.
CancellationToken
)
=>
vscode
.
ProviderResult
<
vscode
.
Range
[]
>
,
public
callback
:
(
document
:
vscode
.
TextDocument
,
range
:
vscode
.
Range
)
=>
void
)
{
}
...
...
@@ -464,7 +466,7 @@ class ExtHostCommentController implements vscode.CommentController {
return
commentThread
;
}
registerCommentingRangeProvider
(
provider
:
(
uri
:
vscode
.
Uri
,
token
:
vscode
.
CancellationToken
)
=>
vscode
.
ProviderResult
<
vscode
.
Range
[]
>
,
callback
:
(
uri
:
vscode
.
Uri
,
range
:
vscode
.
Range
)
=>
void
)
{
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
);
}
...
...
src/vs/workbench/contrib/comments/common/commentModel.ts
浏览文件 @
905248fa
...
...
@@ -41,7 +41,7 @@ export class ResourceWithCommentThreads {
constructor
(
resource
:
URI
,
commentThreads
:
CommentThread
[])
{
this
.
id
=
resource
.
toString
();
this
.
resource
=
resource
;
this
.
commentThreads
=
commentThreads
.
map
(
thread
=>
ResourceWithCommentThreads
.
createCommentNode
(
resource
,
thread
));
this
.
commentThreads
=
commentThreads
.
filter
(
thread
=>
thread
.
comments
.
length
).
map
(
thread
=>
ResourceWithCommentThreads
.
createCommentNode
(
resource
,
thread
));
}
public
static
createCommentNode
(
resource
:
URI
,
commentThread
:
CommentThread
):
CommentNode
{
...
...
@@ -99,14 +99,20 @@ export class CommentsModel {
// Find comment node on resource that is that thread and replace it
const
index
=
firstIndex
(
matchingResourceData
.
commentThreads
,
(
commentThread
)
=>
commentThread
.
threadId
===
thread
.
threadId
);
if
(
index
>=
0
)
{
matchingResourceData
.
commentThreads
[
index
]
=
ResourceWithCommentThreads
.
createCommentNode
(
URI
.
parse
(
matchingResourceData
.
id
),
thread
);
}
else
{
matchingResourceData
.
commentThreads
.
push
(
ResourceWithCommentThreads
.
createCommentNode
(
URI
.
parse
(
matchingResourceData
.
id
),
thread
));
}
});
added
.
forEach
(
thread
=>
{
const
existingResource
=
threadsForOwner
.
filter
(
resourceWithThreads
=>
resourceWithThreads
.
resource
.
toString
()
===
thread
.
resource
);
if
(
existingResource
.
length
)
{
const
resource
=
existingResource
[
0
];
if
(
thread
.
comments
.
length
)
{
resource
.
commentThreads
.
push
(
ResourceWithCommentThreads
.
createCommentNode
(
resource
.
resource
,
thread
));
}
}
else
{
threadsForOwner
.
push
(
new
ResourceWithCommentThreads
(
URI
.
parse
(
thread
.
resource
),
[
thread
]));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录