Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
52306b40
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,发现更多精彩内容 >>
提交
52306b40
编写于
2月 28, 2019
作者:
R
Rachel Macfarlane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix memory leak in commentThreadWidget
上级
09d4f006
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
29 deletion
+33
-29
src/vs/workbench/contrib/comments/electron-browser/commentThreadWidget.ts
.../contrib/comments/electron-browser/commentThreadWidget.ts
+33
-29
未找到文件。
src/vs/workbench/contrib/comments/electron-browser/commentThreadWidget.ts
浏览文件 @
52306b40
...
...
@@ -11,7 +11,7 @@ import { Action } from 'vs/base/common/actions';
import
*
as
arrays
from
'
vs/base/common/arrays
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
ICodeEditor
,
IEditorMouseEvent
,
MouseTargetType
}
from
'
vs/editor/browser/editorBrowser
'
;
...
...
@@ -69,7 +69,7 @@ export class ReviewZoneWidget extends ZoneWidget {
private
_owner
:
string
;
private
_pendingComment
:
string
;
private
_draftMode
:
modes
.
DraftMode
;
private
_
localToDispose
:
IDisposable
[];
private
_
submitActionsDisposables
:
IDisposable
[];
private
_globalToDispose
:
IDisposable
[];
private
_markdownRenderer
:
MarkdownRenderer
;
private
_styleElement
:
HTMLStyleElement
;
...
...
@@ -117,7 +117,7 @@ export class ReviewZoneWidget extends ZoneWidget {
this
.
_draftMode
=
draftMode
;
this
.
_isCollapsed
=
commentThread
.
collapsibleState
!==
modes
.
CommentThreadCollapsibleState
.
Expanded
;
this
.
_globalToDispose
=
[];
this
.
_
localToDispose
=
[];
this
.
_
disposables
=
[];
this
.
_formActions
=
null
;
this
.
create
();
...
...
@@ -296,12 +296,14 @@ export class ReviewZoneWidget extends ZoneWidget {
}
updateDraftMode
(
draftMode
:
modes
.
DraftMode
)
{
this
.
_draftMode
=
draftMode
;
if
(
this
.
_draftMode
!==
draftMode
)
{
this
.
_draftMode
=
draftMode
;
if
(
this
.
_formActions
)
{
let
model
=
this
.
_commentEditor
.
getModel
();
dom
.
clearNode
(
this
.
_formActions
);
this
.
createCommentWidgetActions
(
this
.
_formActions
,
model
);
if
(
this
.
_formActions
)
{
let
model
=
this
.
_commentEditor
.
getModel
();
dom
.
clearNode
(
this
.
_formActions
);
this
.
createCommentWidgetActions
(
this
.
_formActions
,
model
);
}
}
}
...
...
@@ -316,8 +318,8 @@ export class ReviewZoneWidget extends ZoneWidget {
display
(
lineNumber
:
number
)
{
this
.
_commentGlyph
=
new
CommentGlyphWidget
(
this
.
editor
,
lineNumber
);
this
.
_
localToDispose
.
push
(
this
.
editor
.
onMouseDown
(
e
=>
this
.
onEditorMouseDown
(
e
)));
this
.
_
localToDispose
.
push
(
this
.
editor
.
onMouseUp
(
e
=>
this
.
onEditorMouseUp
(
e
)));
this
.
_
disposables
.
push
(
this
.
editor
.
onMouseDown
(
e
=>
this
.
onEditorMouseDown
(
e
)));
this
.
_
disposables
.
push
(
this
.
editor
.
onMouseUp
(
e
=>
this
.
onEditorMouseUp
(
e
)));
let
headHeight
=
Math
.
ceil
(
this
.
editor
.
getConfiguration
().
lineHeight
*
1.2
);
this
.
_headElement
.
style
.
height
=
`
${
headHeight
}
px`
;
this
.
_headElement
.
style
.
lineHeight
=
this
.
_headElement
.
style
.
height
;
...
...
@@ -343,12 +345,12 @@ export class ReviewZoneWidget extends ZoneWidget {
});
const
resource
=
URI
.
parse
(
`
${
COMMENT_SCHEME
}
:commentinput-
${
modeId
}
.md?
${
params
}
`
);
const
model
=
this
.
modelService
.
createModel
(
this
.
_pendingComment
||
''
,
this
.
modeService
.
createByFilepathOrFirstLine
(
resource
.
path
),
resource
,
false
);
this
.
_
localToDispose
.
push
(
model
);
this
.
_
disposables
.
push
(
model
);
this
.
_commentEditor
.
setModel
(
model
);
this
.
_
localToDispose
.
push
(
this
.
_commentEditor
);
this
.
_
localToDispose
.
push
(
this
.
_commentEditor
.
getModel
().
onDidChangeContent
(()
=>
this
.
setCommentEditorDecorations
()));
this
.
_
disposables
.
push
(
this
.
_commentEditor
);
this
.
_
disposables
.
push
(
this
.
_commentEditor
.
getModel
().
onDidChangeContent
(()
=>
this
.
setCommentEditorDecorations
()));
if
((
this
.
_commentThread
as
modes
.
CommentThread2
).
commentThreadHandle
!==
undefined
)
{
this
.
_
localToDispose
.
push
(
this
.
_commentEditor
.
onDidFocusEditorWidget
(()
=>
{
this
.
_
disposables
.
push
(
this
.
_commentEditor
.
onDidFocusEditorWidget
(()
=>
{
let
commentThread
=
this
.
_commentThread
as
modes
.
CommentThread2
;
commentThread
.
input
=
{
uri
:
this
.
_commentEditor
.
getModel
().
uri
,
...
...
@@ -357,7 +359,7 @@ export class ReviewZoneWidget extends ZoneWidget {
this
.
commentService
.
setActiveCommentThread
(
this
.
_commentThread
);
}));
this
.
_
localToDispose
.
push
(
this
.
_commentEditor
.
getModel
().
onDidChangeContent
(()
=>
{
this
.
_
disposables
.
push
(
this
.
_commentEditor
.
getModel
().
onDidChangeContent
(()
=>
{
let
modelContent
=
this
.
_commentEditor
.
getValue
();
let
thread
=
(
this
.
_commentThread
as
modes
.
CommentThread2
);
if
(
thread
.
input
.
uri
===
this
.
_commentEditor
.
getModel
().
uri
&&
thread
.
input
.
value
!==
modelContent
)
{
...
...
@@ -367,7 +369,7 @@ export class ReviewZoneWidget extends ZoneWidget {
}
}));
this
.
_
localToDispose
.
push
((
this
.
_commentThread
as
modes
.
CommentThread2
).
onDidChangeInput
(
input
=>
{
this
.
_
disposables
.
push
((
this
.
_commentThread
as
modes
.
CommentThread2
).
onDidChangeInput
(
input
=>
{
let
thread
=
(
this
.
_commentThread
as
modes
.
CommentThread2
);
if
(
thread
.
input
.
uri
!==
this
.
_commentEditor
.
getModel
().
uri
)
{
...
...
@@ -389,7 +391,7 @@ export class ReviewZoneWidget extends ZoneWidget {
}
}));
this
.
_
localToDispose
.
push
((
this
.
_commentThread
as
modes
.
CommentThread2
).
onDidChangeComments
(
_
=>
{
this
.
_
disposables
.
push
((
this
.
_commentThread
as
modes
.
CommentThread2
).
onDidChangeComments
(
_
=>
{
this
.
update
(
this
.
_commentThread
);
}));
}
...
...
@@ -406,7 +408,7 @@ export class ReviewZoneWidget extends ZoneWidget {
}
}
this
.
_
localToDispose
.
push
(
this
.
_commentEditor
.
onKeyDown
((
ev
:
IKeyboardEvent
)
=>
{
this
.
_
disposables
.
push
(
this
.
_commentEditor
.
onKeyDown
((
ev
:
IKeyboardEvent
)
=>
{
const
hasExistingComments
=
this
.
_commentThread
.
comments
.
length
>
0
;
if
(
this
.
_commentEditor
.
getModel
().
getValueLength
()
===
0
&&
ev
.
keyCode
===
KeyCode
.
Escape
)
{
...
...
@@ -432,7 +434,7 @@ export class ReviewZoneWidget extends ZoneWidget {
if
((
this
.
_commentThread
as
modes
.
CommentThread2
).
commentThreadHandle
!==
undefined
)
{
this
.
createCommentWidgetActions2
(
this
.
_formActions
,
model
);
this
.
_
localToDispose
.
push
((
this
.
_commentThread
as
modes
.
CommentThread2
).
onDidChangeAcceptInputCommands
(
_
=>
{
this
.
_
disposables
.
push
((
this
.
_commentThread
as
modes
.
CommentThread2
).
onDidChangeAcceptInputCommands
(
_
=>
{
dom
.
clearNode
(
this
.
_formActions
);
this
.
createCommentWidgetActions2
(
this
.
_formActions
,
model
);
}));
...
...
@@ -471,12 +473,14 @@ export class ReviewZoneWidget extends ZoneWidget {
}
private
createCommentWidgetActions
(
container
:
HTMLElement
,
model
:
ITextModel
)
{
dispose
(
this
.
_submitActionsDisposables
);
const
button
=
new
Button
(
container
);
this
.
_
localToDispose
.
push
(
attachButtonStyler
(
button
,
this
.
themeService
));
this
.
_
submitActionsDisposables
.
push
(
attachButtonStyler
(
button
,
this
.
themeService
));
button
.
label
=
'
Add comment
'
;
button
.
enabled
=
model
.
getValueLength
()
>
0
;
this
.
_
localToDispose
.
push
(
this
.
_commentEditor
.
onDidChangeModelContent
(
_
=>
{
this
.
_
submitActionsDisposables
.
push
(
this
.
_commentEditor
.
onDidChangeModelContent
(
_
=>
{
if
(
this
.
_commentEditor
.
getValue
())
{
button
.
enabled
=
true
;
}
else
{
...
...
@@ -498,7 +502,7 @@ export class ReviewZoneWidget extends ZoneWidget {
const
deleteDraftLabel
=
this
.
commentService
.
getDeleteDraftLabel
(
this
.
_owner
);
if
(
deleteDraftLabel
)
{
const
deletedraftButton
=
new
Button
(
container
);
this
.
_
d
isposables
.
push
(
attachButtonStyler
(
deletedraftButton
,
this
.
themeService
));
this
.
_
submitActionsD
isposables
.
push
(
attachButtonStyler
(
deletedraftButton
,
this
.
themeService
));
deletedraftButton
.
label
=
deleteDraftLabel
;
deletedraftButton
.
enabled
=
true
;
...
...
@@ -514,7 +518,7 @@ export class ReviewZoneWidget extends ZoneWidget {
const
submitDraftLabel
=
this
.
commentService
.
getFinishDraftLabel
(
this
.
_owner
);
if
(
submitDraftLabel
)
{
const
submitdraftButton
=
new
Button
(
container
);
this
.
_
d
isposables
.
push
(
attachButtonStyler
(
submitdraftButton
,
this
.
themeService
));
this
.
_
submitActionsD
isposables
.
push
(
attachButtonStyler
(
submitdraftButton
,
this
.
themeService
));
submitdraftButton
.
label
=
this
.
commentService
.
getFinishDraftLabel
(
this
.
_owner
);
submitdraftButton
.
enabled
=
true
;
...
...
@@ -540,7 +544,7 @@ export class ReviewZoneWidget extends ZoneWidget {
draftButton
.
label
=
this
.
commentService
.
getStartDraftLabel
(
this
.
_owner
);
draftButton
.
enabled
=
model
.
getValueLength
()
>
0
;
this
.
_
localToDispose
.
push
(
this
.
_commentEditor
.
onDidChangeModelContent
(
_
=>
{
this
.
_
submitActionsDisposables
.
push
(
this
.
_commentEditor
.
onDidChangeModelContent
(
_
=>
{
if
(
this
.
_commentEditor
.
getValue
())
{
draftButton
.
enabled
=
true
;
}
else
{
...
...
@@ -571,12 +575,12 @@ export class ReviewZoneWidget extends ZoneWidget {
commentThread
.
acceptInputCommands
.
reverse
().
forEach
(
command
=>
{
const
button
=
new
Button
(
container
);
this
.
_
localToDispose
.
push
(
attachButtonStyler
(
button
,
this
.
themeService
));
this
.
_
disposables
.
push
(
attachButtonStyler
(
button
,
this
.
themeService
));
button
.
label
=
command
.
title
;
let
commandId
=
command
.
id
;
let
args
=
command
.
arguments
||
[];
this
.
_
localToDispose
.
push
(
button
.
onDidClick
(
async
()
=>
{
this
.
_
disposables
.
push
(
button
.
onDidClick
(
async
()
=>
{
commentThread
.
input
=
{
uri
:
this
.
_commentEditor
.
getModel
().
uri
,
value
:
this
.
_commentEditor
.
getValue
()
...
...
@@ -707,8 +711,8 @@ export class ReviewZoneWidget extends ZoneWidget {
}
this
.
_reviewThreadReplyButton
.
textContent
=
nls
.
localize
(
'
reply
'
,
"
Reply...
"
);
// bind click/escape actions for reviewThreadReplyButton and textArea
this
.
_
localToDispose
.
push
(
dom
.
addDisposableListener
(
this
.
_reviewThreadReplyButton
,
'
click
'
,
_
=>
this
.
expandReplyArea
()));
this
.
_
localToDispose
.
push
(
dom
.
addDisposableListener
(
this
.
_reviewThreadReplyButton
,
'
focus
'
,
_
=>
this
.
expandReplyArea
()));
this
.
_
disposables
.
push
(
dom
.
addDisposableListener
(
this
.
_reviewThreadReplyButton
,
'
click
'
,
_
=>
this
.
expandReplyArea
()));
this
.
_
disposables
.
push
(
dom
.
addDisposableListener
(
this
.
_reviewThreadReplyButton
,
'
focus
'
,
_
=>
this
.
expandReplyArea
()));
this
.
_commentEditor
.
onDidBlurEditorWidget
(()
=>
{
if
(
this
.
_commentEditor
.
getModel
().
getValueLength
()
===
0
&&
dom
.
hasClass
(
this
.
_commentForm
,
'
expand
'
))
{
...
...
@@ -920,7 +924,7 @@ export class ReviewZoneWidget extends ZoneWidget {
}
this
.
_globalToDispose
.
forEach
(
global
=>
global
.
dispose
());
this
.
_
localToDispose
.
forEach
(
local
=>
local
.
dispose
());
this
.
_
submitActionsDisposables
.
forEach
(
local
=>
local
.
dispose
());
this
.
_onDidClose
.
fire
(
undefined
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录