Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
54c9ebe8
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
54c9ebe8
编写于
10月 23, 2018
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pending comment caching in editor comment contribution
上级
f46d1a43
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
53 addition
and
13 deletion
+53
-13
src/vs/workbench/parts/comments/electron-browser/commentThreadWidget.ts
...ch/parts/comments/electron-browser/commentThreadWidget.ts
+16
-1
src/vs/workbench/parts/comments/electron-browser/commentsEditorContribution.ts
...s/comments/electron-browser/commentsEditorContribution.ts
+37
-12
未找到文件。
src/vs/workbench/parts/comments/electron-browser/commentThreadWidget.ts
浏览文件 @
54c9ebe8
...
...
@@ -64,6 +64,7 @@ export class ReviewZoneWidget extends ZoneWidget {
private
_commentThread
:
modes
.
CommentThread
;
private
_commentGlyph
:
CommentGlyphWidget
;
private
_owner
:
number
;
private
_pendingComment
:
string
;
private
_localToDispose
:
IDisposable
[];
private
_globalToDispose
:
IDisposable
[];
private
_markdownRenderer
:
MarkdownRenderer
;
...
...
@@ -89,12 +90,14 @@ export class ReviewZoneWidget extends ZoneWidget {
editor
:
ICodeEditor
,
owner
:
number
,
commentThread
:
modes
.
CommentThread
,
pendingComment
:
string
,
options
:
IOptions
=
{}
)
{
super
(
editor
,
options
);
this
.
_resizeObserver
=
null
;
this
.
_owner
=
owner
;
this
.
_commentThread
=
commentThread
;
this
.
_pendingComment
=
pendingComment
;
this
.
_isCollapsed
=
commentThread
.
collapsibleState
!==
modes
.
CommentThreadCollapsibleState
.
Expanded
;
this
.
_globalToDispose
=
[];
this
.
_localToDispose
=
[];
...
...
@@ -144,6 +147,18 @@ export class ReviewZoneWidget extends ZoneWidget {
this
.
editor
.
revealRangeInCenter
(
this
.
_commentThread
.
range
);
}
public
getPendingComment
():
string
{
if
(
this
.
_commentEditor
)
{
let
model
=
this
.
_commentEditor
.
getModel
();
if
(
model
.
getValueLength
()
>
0
)
{
// checking length is cheap
return
model
.
getValue
();
}
}
return
null
;
}
protected
_fillContainer
(
container
:
HTMLElement
):
void
{
this
.
setCssClass
(
'
review-widget
'
);
this
.
_headElement
=
<
HTMLDivElement
>
dom
.
$
(
'
.head
'
);
...
...
@@ -264,7 +279,7 @@ export class ReviewZoneWidget extends ZoneWidget {
this
.
_commentEditor
=
this
.
instantiationService
.
createInstance
(
SimpleCommentEditor
,
this
.
_commentForm
,
SimpleCommentEditor
.
getEditorOptions
());
const
modeId
=
hasExistingComments
?
this
.
_commentThread
.
threadId
:
++
INMEM_MODEL_ID
;
const
resource
=
URI
.
parse
(
`
${
COMMENT_SCHEME
}
:commentinput-
${
modeId
}
.md`
);
const
model
=
this
.
modelService
.
createModel
(
''
,
this
.
modeService
.
getOrCreateModeByFilepathOrFirstLine
(
resource
.
path
),
resource
,
true
);
const
model
=
this
.
modelService
.
createModel
(
this
.
_pendingComment
||
''
,
this
.
modeService
.
getOrCreateModeByFilepathOrFirstLine
(
resource
.
path
),
resource
,
true
);
this
.
_localToDispose
.
push
(
model
);
this
.
_commentEditor
.
setModel
(
model
);
this
.
_localToDispose
.
push
(
this
.
_commentEditor
);
...
...
src/vs/workbench/parts/comments/electron-browser/commentsEditorContribution.ts
浏览文件 @
54c9ebe8
...
...
@@ -172,6 +172,7 @@ export class ReviewController implements IEditorContribution {
private
mouseDownInfo
:
{
lineNumber
:
number
}
|
null
=
null
;
private
_commentingRangeSpaceReserved
=
false
;
private
_pendingCommentCache
:
{
[
key
:
number
]:
{
[
key
:
string
]:
string
}
};
constructor
(
editor
:
ICodeEditor
,
...
...
@@ -191,6 +192,7 @@ export class ReviewController implements IEditorContribution {
this
.
localToDispose
=
[];
this
.
_commentInfos
=
[];
this
.
_commentWidgets
=
[];
this
.
_pendingCommentCache
=
{};
this
.
_newCommentWidget
=
null
;
this
.
_reviewPanelVisible
=
ctxReviewPanelVisible
.
bindTo
(
contextKeyService
);
...
...
@@ -315,10 +317,8 @@ export class ReviewController implements IEditorContribution {
this
.
_newCommentWidget
=
null
;
}
this
.
_commentWidgets
.
forEach
(
zone
=>
{
zone
.
dispose
();
});
this
.
_commentWidgets
=
[];
this
.
removeCommentWidgetsAndStoreCache
();
this
.
localToDispose
.
push
(
this
.
editor
.
onMouseDown
(
e
=>
this
.
onEditorMouseDown
(
e
)));
this
.
localToDispose
.
push
(
this
.
editor
.
onMouseUp
(
e
=>
this
.
onEditorMouseUp
(
e
)));
...
...
@@ -355,7 +355,7 @@ export class ReviewController implements IEditorContribution {
}
});
added
.
forEach
(
thread
=>
{
let
zoneWidget
=
new
ReviewZoneWidget
(
this
.
instantiationService
,
this
.
modeService
,
this
.
modelService
,
this
.
themeService
,
this
.
commentService
,
this
.
openerService
,
this
.
dialogService
,
this
.
notificationService
,
this
.
editor
,
e
.
owner
,
thread
,
{});
let
zoneWidget
=
new
ReviewZoneWidget
(
this
.
instantiationService
,
this
.
modeService
,
this
.
modelService
,
this
.
themeService
,
this
.
commentService
,
this
.
openerService
,
this
.
dialogService
,
this
.
notificationService
,
this
.
editor
,
e
.
owner
,
thread
,
null
,
{});
zoneWidget
.
display
(
thread
.
range
.
startLineNumber
,
this
.
_commentingRangeDecorator
.
commentsOptions
);
this
.
_commentWidgets
.
push
(
zoneWidget
);
this
.
_commentInfos
.
filter
(
info
=>
info
.
owner
===
e
.
owner
)[
0
].
threads
.
push
(
thread
);
...
...
@@ -389,7 +389,7 @@ export class ReviewController implements IEditorContribution {
},
reply
:
replyCommand
,
collapsibleState
:
CommentThreadCollapsibleState
.
Expanded
,
},
{});
},
null
,
{});
this
.
localToDispose
.
push
(
this
.
_newCommentWidget
.
onDidClose
(
e
=>
{
this
.
_newCommentWidget
=
null
;
...
...
@@ -462,6 +462,7 @@ export class ReviewController implements IEditorContribution {
}
setComments
(
commentInfos
:
modes
.
CommentInfo
[]):
void
{
// todo setComments should read from pendingCommentCache
this
.
_commentInfos
=
commentInfos
;
let
lineDecorationsWidth
:
number
=
this
.
editor
.
getConfiguration
().
layoutInfo
.
decorationsWidth
;
...
...
@@ -494,15 +495,16 @@ export class ReviewController implements IEditorContribution {
}
// create viewzones
this
.
_commentWidgets
.
forEach
(
zone
=>
{
zone
.
dispose
();
});
this
.
_commentWidgets
=
[];
this
.
removeCommentWidgetsAndStoreCache
();
this
.
_commentInfos
.
forEach
(
info
=>
{
let
providerCacheStore
=
this
.
_pendingCommentCache
[
info
.
owner
];
info
.
threads
.
forEach
(
thread
=>
{
let
zoneWidget
=
new
ReviewZoneWidget
(
this
.
instantiationService
,
this
.
modeService
,
this
.
modelService
,
this
.
themeService
,
this
.
commentService
,
this
.
openerService
,
this
.
dialogService
,
this
.
notificationService
,
this
.
editor
,
info
.
owner
,
thread
,
{});
let
pendingComment
:
string
=
null
;
if
(
providerCacheStore
)
{
pendingComment
=
providerCacheStore
[
thread
.
threadId
];
}
let
zoneWidget
=
new
ReviewZoneWidget
(
this
.
instantiationService
,
this
.
modeService
,
this
.
modelService
,
this
.
themeService
,
this
.
commentService
,
this
.
openerService
,
this
.
dialogService
,
this
.
notificationService
,
this
.
editor
,
info
.
owner
,
thread
,
pendingComment
,
{});
zoneWidget
.
display
(
thread
.
range
.
startLineNumber
,
this
.
_commentingRangeDecorator
.
commentsOptions
);
this
.
_commentWidgets
.
push
(
zoneWidget
);
});
...
...
@@ -530,6 +532,29 @@ export class ReviewController implements IEditorContribution {
this
.
editor
.
focus
();
this
.
editor
.
revealRangeInCenter
(
this
.
editor
.
getSelection
());
}
removeCommentWidgetsAndStoreCache
()
{
if
(
this
.
_commentWidgets
)
{
this
.
_commentWidgets
.
forEach
(
zone
=>
{
let
pendingComment
=
zone
.
getPendingComment
();
if
(
pendingComment
)
{
// cache pendingComment for later recovery
let
providerCacheStore
=
this
.
_pendingCommentCache
[
zone
.
owner
];
if
(
!
providerCacheStore
)
{
this
.
_pendingCommentCache
[
zone
.
owner
]
=
{};
providerCacheStore
=
this
.
_pendingCommentCache
[
zone
.
owner
];
}
providerCacheStore
[
zone
.
commentThread
.
threadId
]
=
pendingComment
;
}
zone
.
dispose
();
});
}
this
.
_commentWidgets
=
[];
}
}
export
class
NextCommentThreadAction
extends
EditorAction
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录