Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d026ae2a
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,发现更多精彩内容 >>
提交
d026ae2a
编写于
9月 25, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #102665.
上级
c49d699a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
38 deletion
+46
-38
src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts
...workbench/contrib/comments/browser/commentThreadWidget.ts
+46
-38
未找到文件。
src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts
浏览文件 @
d026ae2a
...
...
@@ -61,10 +61,13 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
protected
_actionbarWidget
!
:
ActionBar
;
private
_bodyElement
!
:
HTMLElement
;
private
_parentEditor
:
ICodeEditor
;
private
_commentEditor
?:
ICodeEditor
;
private
_commentsElement
!
:
HTMLElement
;
private
_commentElements
:
CommentNode
[]
=
[];
private
_commentForm
?:
HTMLElement
;
private
_commentReplyComponent
?:
{
editor
:
ICodeEditor
;
form
:
HTMLElement
;
commentEditorIsEmpty
:
IContextKey
<
boolean
>
;
};
private
_reviewThreadReplyButton
!
:
HTMLElement
;
private
_resizeObserver
:
any
;
private
readonly
_onDidClose
=
new
Emitter
<
ReviewZoneWidget
|
undefined
>
();
...
...
@@ -82,7 +85,6 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
private
_contextKeyService
:
IContextKeyService
;
private
_threadIsEmpty
:
IContextKey
<
boolean
>
;
private
_commentThreadContextValue
:
IContextKey
<
string
>
;
private
_commentEditorIsEmpty
?:
IContextKey
<
boolean
>
;
private
_commentFormActions
!
:
CommentFormActions
;
private
_scopedInstatiationService
:
IInstantiationService
;
private
_focusedComment
:
number
|
undefined
=
undefined
;
...
...
@@ -199,8 +201,8 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
}
public
getPendingComment
():
string
|
null
{
if
(
this
.
_comment
Editor
)
{
let
model
=
this
.
_comment
E
ditor
.
getModel
();
if
(
this
.
_comment
ReplyComponent
)
{
let
model
=
this
.
_comment
ReplyComponent
.
e
ditor
.
getModel
();
if
(
model
&&
model
.
getValueLength
()
>
0
)
{
// checking length is cheap
return
model
.
getValue
();
...
...
@@ -367,8 +369,8 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
}
}
if
(
!
this
.
_reviewThreadReplyButton
&&
this
.
_comment
Editor
&&
this
.
_commentForm
)
{
this
.
createReplyButton
(
this
.
_comment
Editor
,
this
.
_commentF
orm
);
if
(
!
this
.
_reviewThreadReplyButton
&&
this
.
_comment
ReplyComponent
)
{
this
.
createReplyButton
(
this
.
_comment
ReplyComponent
.
editor
,
this
.
_commentReplyComponent
.
f
orm
);
}
if
(
this
.
_commentThread
.
comments
&&
this
.
_commentThread
.
comments
.
length
===
0
)
{
...
...
@@ -400,11 +402,11 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
}
protected
_onWidth
(
widthInPixel
:
number
):
void
{
this
.
_comment
Editor
?
.
layout
({
height
:
5
*
18
,
width
:
widthInPixel
-
54
/* margin 20px * 10 + scrollbar 14px*/
});
this
.
_comment
ReplyComponent
?.
editor
.
layout
({
height
:
5
*
18
,
width
:
widthInPixel
-
54
/* margin 20px * 10 + scrollbar 14px*/
});
}
protected
_doLayout
(
heightInPixel
:
number
,
widthInPixel
:
number
):
void
{
this
.
_comment
Editor
?
.
layout
({
height
:
5
*
18
,
width
:
widthInPixel
-
54
/* margin 20px * 10 + scrollbar 14px*/
});
this
.
_comment
ReplyComponent
?.
editor
.
layout
({
height
:
5
*
18
,
width
:
widthInPixel
-
54
/* margin 20px * 10 + scrollbar 14px*/
});
}
display
(
lineNumber
:
number
)
{
...
...
@@ -468,20 +470,20 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
// If there are no existing comments, place focus on the text area. This must be done after show, which also moves focus.
// if this._commentThread.comments is undefined, it doesn't finish initialization yet, so we don't focus the editor immediately.
if
(
!
this
.
_commentThread
.
readOnly
)
{
if
(
!
this
.
_commentThread
.
readOnly
&&
this
.
_commentReplyComponent
)
{
if
(
!
this
.
_commentThread
.
comments
||
!
this
.
_commentThread
.
comments
.
length
)
{
this
.
_comment
Editor
?
.
focus
();
}
else
if
(
this
.
_comment
Editor
&&
this
.
_commentE
ditor
.
getModel
()
!
.
getValueLength
()
>
0
)
{
this
.
_comment
ReplyComponent
.
editor
.
focus
();
}
else
if
(
this
.
_comment
ReplyComponent
.
e
ditor
.
getModel
()
!
.
getValueLength
()
>
0
)
{
this
.
expandReplyArea
();
}
}
this
.
_commentThreadDisposables
.
push
(
this
.
_commentThread
.
onDidChangeReadOnly
(()
=>
{
if
(
this
.
_comment
Form
)
{
if
(
this
.
_comment
ReplyComponent
)
{
if
(
this
.
_commentThread
.
readOnly
)
{
this
.
_comment
F
orm
.
style
.
display
=
'
none
'
;
this
.
_comment
ReplyComponent
.
f
orm
.
style
.
display
=
'
none
'
;
}
else
{
this
.
_comment
F
orm
.
style
.
display
=
'
block
'
;
this
.
_comment
ReplyComponent
.
f
orm
.
style
.
display
=
'
block
'
;
}
}
else
{
if
(
!
this
.
_commentThread
.
readOnly
)
{
...
...
@@ -493,10 +495,16 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
private
createCommentForm
()
{
const
hasExistingComments
=
this
.
_commentThread
.
comments
&&
this
.
_commentThread
.
comments
.
length
>
0
;
this
.
_commentForm
=
dom
.
append
(
this
.
_bodyElement
,
dom
.
$
(
'
.comment-form
'
));
this
.
_commentEditor
=
this
.
_scopedInstatiationService
.
createInstance
(
SimpleCommentEditor
,
this
.
_commentForm
,
SimpleCommentEditor
.
getEditorOptions
(),
this
.
_parentEditor
,
this
);
this
.
_commentEditorIsEmpty
=
CommentContextKeys
.
commentIsEmpty
.
bindTo
(
this
.
_contextKeyService
);
this
.
_commentEditorIsEmpty
.
set
(
!
this
.
_pendingComment
);
const
commentForm
=
dom
.
append
(
this
.
_bodyElement
,
dom
.
$
(
'
.comment-form
'
));
const
commentEditor
=
this
.
_scopedInstatiationService
.
createInstance
(
SimpleCommentEditor
,
commentForm
,
SimpleCommentEditor
.
getEditorOptions
(),
this
.
_parentEditor
,
this
);
const
commentEditorIsEmpty
=
CommentContextKeys
.
commentIsEmpty
.
bindTo
(
this
.
_contextKeyService
);
commentEditorIsEmpty
.
set
(
!
this
.
_pendingComment
);
this
.
_commentReplyComponent
=
{
form
:
commentForm
,
editor
:
commentEditor
,
commentEditorIsEmpty
};
const
modeId
=
generateUuid
()
+
'
-
'
+
(
hasExistingComments
?
this
.
_commentThread
.
threadId
:
++
INMEM_MODEL_ID
);
const
params
=
JSON
.
stringify
({
...
...
@@ -512,28 +520,28 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
const
model
=
this
.
modelService
.
createModel
(
this
.
_pendingComment
||
''
,
this
.
modeService
.
createByFilepathOrFirstLine
(
resource
),
resource
,
false
);
this
.
_disposables
.
add
(
model
);
this
.
_
commentEditor
.
setModel
(
model
);
this
.
_disposables
.
add
(
this
.
_
commentEditor
);
this
.
_disposables
.
add
(
this
.
_
commentEditor
.
getModel
()
!
.
onDidChangeContent
(()
=>
{
commentEditor
.
setModel
(
model
);
this
.
_disposables
.
add
(
commentEditor
);
this
.
_disposables
.
add
(
commentEditor
.
getModel
()
!
.
onDidChangeContent
(()
=>
{
this
.
setCommentEditorDecorations
();
this
.
_commentEditorIsEmpty
?.
set
(
!
this
.
_commentEditor
?
.
getValue
());
commentEditorIsEmpty
?.
set
(
!
commentEditor
.
getValue
());
}));
this
.
createTextModelListener
(
this
.
_commentEditor
,
this
.
_
commentForm
);
this
.
createTextModelListener
(
commentEditor
,
commentForm
);
this
.
setCommentEditorDecorations
();
// Only add the additional step of clicking a reply button to expand the textarea when there are existing comments
if
(
hasExistingComments
)
{
this
.
createReplyButton
(
this
.
_commentEditor
,
this
.
_
commentForm
);
this
.
createReplyButton
(
commentEditor
,
commentForm
);
}
else
{
if
(
this
.
_commentThread
.
comments
&&
this
.
_commentThread
.
comments
.
length
===
0
)
{
this
.
expandReplyArea
();
}
}
this
.
_error
=
dom
.
append
(
this
.
_
commentForm
,
dom
.
$
(
'
.validation-error.hidden
'
));
this
.
_error
=
dom
.
append
(
commentForm
,
dom
.
$
(
'
.validation-error.hidden
'
));
this
.
_formActions
=
dom
.
append
(
this
.
_
commentForm
,
dom
.
$
(
'
.form-actions
'
));
this
.
_formActions
=
dom
.
append
(
commentForm
,
dom
.
$
(
'
.form-actions
'
));
this
.
createCommentWidgetActions
(
this
.
_formActions
,
model
);
this
.
createCommentWidgetActionsListener
();
}
...
...
@@ -661,7 +669,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
}
action
.
run
({
thread
:
this
.
_commentThread
,
text
:
this
.
_comment
Editor
?
.
getValue
(),
text
:
this
.
_comment
ReplyComponent
?.
editor
.
getValue
(),
$mid
:
8
});
...
...
@@ -718,19 +726,19 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
}
private
expandReplyArea
()
{
if
(
!
this
.
_comment
Form
?
.
classList
.
contains
(
'
expand
'
))
{
this
.
_comment
Form
?
.
classList
.
add
(
'
expand
'
);
this
.
_comment
Editor
?
.
focus
();
if
(
!
this
.
_comment
ReplyComponent
?.
form
.
classList
.
contains
(
'
expand
'
))
{
this
.
_comment
ReplyComponent
?.
form
.
classList
.
add
(
'
expand
'
);
this
.
_comment
ReplyComponent
?.
editor
.
focus
();
}
}
private
hideReplyArea
()
{
if
(
this
.
_comment
Editor
)
{
this
.
_comment
E
ditor
.
setValue
(
''
);
this
.
_comment
E
ditor
.
getDomNode
()
!
.
style
.
outline
=
''
;
if
(
this
.
_comment
ReplyComponent
)
{
this
.
_comment
ReplyComponent
.
e
ditor
.
setValue
(
''
);
this
.
_comment
ReplyComponent
.
e
ditor
.
getDomNode
()
!
.
style
.
outline
=
''
;
}
this
.
_pendingComment
=
''
;
this
.
_comment
Form
?
.
classList
.
remove
(
'
expand
'
);
this
.
_comment
ReplyComponent
?.
form
.
classList
.
remove
(
'
expand
'
);
this
.
_error
.
textContent
=
''
;
this
.
_error
.
classList
.
add
(
'
hidden
'
);
}
...
...
@@ -777,7 +785,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
}
if
(
!
this
.
_commentThread
.
comments
||
!
this
.
_commentThread
.
comments
.
length
)
{
this
.
_comment
Editor
?
.
focus
();
this
.
_comment
ReplyComponent
?.
editor
.
focus
();
}
this
.
_relayout
(
computedLinesNumber
);
...
...
@@ -785,7 +793,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
}
private
setCommentEditorDecorations
()
{
const
model
=
this
.
_comment
Editor
&&
this
.
_commentE
ditor
.
getModel
();
const
model
=
this
.
_comment
ReplyComponent
&&
this
.
_commentReplyComponent
.
e
ditor
.
getModel
();
if
(
model
)
{
const
valueLength
=
model
.
getValueLength
();
const
hasExistingComments
=
this
.
_commentThread
.
comments
&&
this
.
_commentThread
.
comments
.
length
>
0
;
...
...
@@ -809,7 +817,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
}
}];
this
.
_comment
Editor
?
.
setDecorations
(
COMMENTEDITOR_DECORATION_KEY
,
decorations
);
this
.
_comment
ReplyComponent
?.
editor
.
setDecorations
(
COMMENTEDITOR_DECORATION_KEY
,
decorations
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录