Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
82127d5c
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,发现更多精彩内容 >>
提交
82127d5c
编写于
5月 20, 2019
作者:
R
Rachel Macfarlane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Scope context key service by thread and comment
上级
7285e765
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
56 deletion
+33
-56
src/vs/workbench/contrib/comments/browser/commentMenus.ts
src/vs/workbench/contrib/comments/browser/commentMenus.ts
+11
-21
src/vs/workbench/contrib/comments/browser/commentNode.ts
src/vs/workbench/contrib/comments/browser/commentNode.ts
+7
-6
src/vs/workbench/contrib/comments/browser/commentService.ts
src/vs/workbench/contrib/comments/browser/commentService.ts
+2
-17
src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts
...workbench/contrib/comments/browser/commentThreadWidget.ts
+13
-12
未找到文件。
src/vs/workbench/contrib/comments/browser/commentMenus.ts
浏览文件 @
82127d5c
...
...
@@ -5,7 +5,7 @@
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IMenu
,
IMenu
Service
,
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IMenuService
,
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IAction
}
from
'
vs/base/common/actions
'
;
import
{
MainThreadCommentController
}
from
'
vs/workbench/api/browser/mainThreadComments
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
...
...
@@ -13,14 +13,9 @@ import { Comment, CommentThread2 } from 'vs/editor/common/modes';
import
{
fillInContextMenuActions
}
from
'
vs/platform/actions/browser/menuEntryActionViewItem
'
;
export
class
CommentMenus
implements
IDisposable
{
private
titleMenu
:
IMenu
;
private
titleActions
:
IAction
[]
=
[];
private
readonly
disposables
:
IDisposable
[]
=
[];
constructor
(
controller
:
MainThreadCommentController
,
private
contextKeyService
:
IContextKeyService
,
@
IContextKeyService
private
contextKeyService
:
IContextKeyService
,
@
IMenuService
private
readonly
menuService
:
IMenuService
,
@
IContextMenuService
private
readonly
contextMenuService
:
IContextMenuService
)
{
...
...
@@ -29,25 +24,23 @@ export class CommentMenus implements IDisposable {
commentControllerKey
.
set
(
controller
.
contextValue
);
}
getCommentThreadTitleActions
(
commentThread
:
CommentThread2
):
IAction
[]
{
return
this
.
getActions
(
MenuId
.
CommentThreadTitle
).
primary
;
getCommentThreadTitleActions
(
commentThread
:
CommentThread2
,
contextKeyService
:
IContextKeyService
):
IAction
[]
{
return
this
.
getActions
(
MenuId
.
CommentThreadTitle
,
contextKeyService
).
primary
;
}
getCommentThreadActions
(
commentThread
:
CommentThread2
):
IAction
[]
{
return
this
.
getActions
(
MenuId
.
CommentThreadActions
).
primary
;
getCommentThreadActions
(
commentThread
:
CommentThread2
,
contextKeyService
:
IContextKeyService
):
IAction
[]
{
return
this
.
getActions
(
MenuId
.
CommentThreadActions
,
contextKeyService
).
primary
;
}
getCommentTitleActions
(
comment
:
Comment
):
IAction
[]
{
return
this
.
getActions
(
MenuId
.
CommentTitle
).
primary
;
getCommentTitleActions
(
comment
:
Comment
,
contextKeyService
:
IContextKeyService
):
IAction
[]
{
return
this
.
getActions
(
MenuId
.
CommentTitle
,
contextKeyService
).
primary
;
}
getCommentActions
(
comment
:
Comment
):
IAction
[]
{
return
this
.
getActions
(
MenuId
.
CommentActions
).
primary
;
getCommentActions
(
comment
:
Comment
,
contextKeyService
:
IContextKeyService
):
IAction
[]
{
return
this
.
getActions
(
MenuId
.
CommentActions
,
contextKeyService
).
primary
;
}
private
getActions
(
menuId
:
MenuId
)
{
const
contextKeyService
=
this
.
contextKeyService
.
createScoped
();
private
getActions
(
menuId
:
MenuId
,
contextKeyService
:
IContextKeyService
)
{
const
menu
=
this
.
menuService
.
createMenu
(
menuId
,
contextKeyService
);
const
primary
:
IAction
[]
=
[];
const
secondary
:
IAction
[]
=
[];
...
...
@@ -56,10 +49,7 @@ export class CommentMenus implements IDisposable {
fillInContextMenuActions
(
menu
,
{
shouldForwardArgs
:
true
},
result
,
this
.
contextMenuService
,
g
=>
true
);
menu
.
dispose
();
contextKeyService
.
dispose
();
return
result
;
}
dispose
():
void
{
...
...
src/vs/workbench/contrib/comments/browser/commentNode.ts
浏览文件 @
82127d5c
...
...
@@ -38,6 +38,7 @@ import { ICommentThreadWidget } from 'vs/workbench/contrib/comments/common/comme
import
{
MenuItemAction
}
from
'
vs/platform/actions/common/actions
'
;
import
{
ContextAwareMenuEntryActionViewItem
}
from
'
vs/platform/actions/browser/menuEntryActionViewItem
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
const
UPDATE_COMMENT_LABEL
=
nls
.
localize
(
'
label.updateComment
'
,
"
Update comment
"
);
const
UPDATE_IN_PROGRESS_LABEL
=
nls
.
localize
(
'
label.updatingComment
'
,
"
Updating comment...
"
);
...
...
@@ -60,6 +61,7 @@ export class CommentNode extends Disposable {
private
_updateCommentButton
:
Button
;
private
_errorEditingContainer
:
HTMLElement
;
private
_isPendingLabel
:
HTMLElement
;
private
_contextKeyService
:
IContextKeyService
;
private
_deleteAction
:
Action
;
protected
actionRunner
?:
IActionRunner
;
...
...
@@ -90,11 +92,13 @@ export class CommentNode extends Disposable {
@
IDialogService
private
dialogService
:
IDialogService
,
@
IKeybindingService
private
keybindingService
:
IKeybindingService
,
@
INotificationService
private
notificationService
:
INotificationService
,
@
IContextMenuService
private
contextMenuService
:
IContextMenuService
@
IContextMenuService
private
contextMenuService
:
IContextMenuService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
)
{
super
();
this
.
_domNode
=
dom
.
$
(
'
div.review-comment
'
);
this
.
_contextKeyService
=
contextKeyService
.
createScoped
(
this
.
_domNode
);
this
.
_domNode
.
tabIndex
=
0
;
const
avatar
=
dom
.
append
(
this
.
_domNode
,
dom
.
$
(
'
div.avatar-container
'
));
if
(
comment
.
userIconPath
)
{
...
...
@@ -168,7 +172,7 @@ export class CommentNode extends Disposable {
}
let
commentMenus
=
this
.
commentService
.
getCommentMenus
(
this
.
owner
);
let
titleActions
=
commentMenus
.
getCommentTitleActions
(
this
.
comment
);
let
titleActions
=
commentMenus
.
getCommentTitleActions
(
this
.
comment
,
this
.
_contextKeyService
);
actions
.
push
(...
titleActions
);
if
(
actions
.
length
)
{
...
...
@@ -408,14 +412,12 @@ export class CommentNode extends Disposable {
uri
:
this
.
_commentEditor
.
getModel
()
!
.
uri
,
value
:
this
.
comment
.
body
.
value
};
this
.
commentService
.
onDidChangeActiveCommentThread
(
commentThread
);
this
.
_commentEditorDisposables
.
push
(
this
.
_commentEditor
.
onDidFocusEditorWidget
(()
=>
{
commentThread
.
input
=
{
uri
:
this
.
_commentEditor
!
.
getModel
()
!
.
uri
,
value
:
this
.
comment
.
body
.
value
};
this
.
commentService
.
onDidChangeActiveCommentThread
(
commentThread
);
}));
this
.
_commentEditorDisposables
.
push
(
this
.
_commentEditor
.
onDidChangeModelContent
(
e
=>
{
...
...
@@ -472,7 +474,6 @@ export class CommentNode extends Disposable {
uri
:
this
.
_commentEditor
.
getModel
()
!
.
uri
,
value
:
newBody
};
this
.
commentService
.
onDidChangeActiveCommentThread
(
commentThread
);
let
commandId
=
this
.
comment
.
editCommand
.
id
;
let
args
=
this
.
comment
.
editCommand
.
arguments
||
[];
...
...
@@ -554,7 +555,7 @@ export class CommentNode extends Disposable {
// }));
let
menus
=
this
.
commentService
.
getCommentMenus
(
this
.
owner
);
let
actions
=
menus
.
getCommentActions
(
this
.
comment
);
let
actions
=
menus
.
getCommentActions
(
this
.
comment
,
this
.
_contextKeyService
);
actions
.
forEach
(
action
=>
{
let
button
=
new
Button
(
formActions
);
...
...
src/vs/workbench/contrib/comments/browser/commentService.ts
浏览文件 @
82127d5c
...
...
@@ -15,8 +15,6 @@ import { assign } from 'vs/base/common/objects';
import
{
ICommentThreadChangedEvent
}
from
'
vs/workbench/contrib/comments/common/commentModel
'
;
import
{
MainThreadCommentController
}
from
'
vs/workbench/api/browser/mainThreadComments
'
;
import
{
CommentMenus
}
from
'
vs/workbench/contrib/comments/browser/commentMenus
'
;
import
{
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
CommentContextKeys
}
from
'
vs/workbench/contrib/comments/common/commentContextKeys
'
;
export
const
ICommentService
=
createDecorator
<
ICommentService
>
(
'
commentService
'
);
...
...
@@ -43,7 +41,6 @@ export interface ICommentService {
readonly
onDidChangeActiveCommentingRange
:
Event
<
{
range
:
Range
,
commentingRangesInfo
:
CommentingRanges
}
>
;
readonly
onDidSetDataProvider
:
Event
<
void
>
;
readonly
onDidDeleteDataProvider
:
Event
<
string
>
;
readonly
contextKeyService
:
IContextKeyService
;
setDocumentComments
(
resource
:
URI
,
commentInfos
:
ICommentInfo
[]):
void
;
setWorkspaceComments
(
owner
:
string
,
commentsByResource
:
CommentThread
[]
|
CommentThread2
[]):
void
;
removeWorkspaceComments
(
owner
:
string
):
void
;
...
...
@@ -70,7 +67,6 @@ export interface ICommentService {
deleteReaction
(
owner
:
string
,
resource
:
URI
,
comment
:
Comment
,
reaction
:
CommentReaction
):
Promise
<
void
>
;
getReactionGroup
(
owner
:
string
):
CommentReaction
[]
|
undefined
;
toggleReaction
(
owner
:
string
,
resource
:
URI
,
thread
:
CommentThread2
,
comment
:
Comment
,
reaction
:
CommentReaction
):
Promise
<
void
>
;
onDidChangeActiveCommentThread
(
commentThread
:
CommentThread
|
null
):
void
;
}
export
class
CommentService
extends
Disposable
implements
ICommentService
{
...
...
@@ -105,21 +101,10 @@ export class CommentService extends Disposable implements ICommentService {
private
_commentControls
=
new
Map
<
string
,
MainThreadCommentController
>
();
private
_commentMenus
=
new
Map
<
string
,
CommentMenus
>
();
private
_activeThreadIsEmpty
:
IContextKey
<
boolean
>
;
contextKeyService
:
IContextKeyService
;
constructor
(
@
IInstantiationService
protected
instantiationService
:
IInstantiationService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
@
IInstantiationService
protected
instantiationService
:
IInstantiationService
)
{
super
();
this
.
contextKeyService
=
contextKeyService
.
createScoped
();
this
.
_activeThreadIsEmpty
=
CommentContextKeys
.
commentThreadIsEmpty
.
bindTo
(
this
.
contextKeyService
);
}
onDidChangeActiveCommentThread
(
commentThread
:
CommentThread
|
null
)
{
this
.
_activeThreadIsEmpty
.
set
(
!!
commentThread
&&
!!
commentThread
.
comments
&&
!!
commentThread
.
comments
.
length
);
}
setDocumentComments
(
resource
:
URI
,
commentInfos
:
ICommentInfo
[]):
void
{
...
...
@@ -161,7 +146,7 @@ export class CommentService extends Disposable implements ICommentService {
let
controller
=
this
.
_commentControls
.
get
(
owner
);
let
menu
=
this
.
instantiationService
.
createInstance
(
CommentMenus
,
controller
!
,
this
.
contextKeyService
);
let
menu
=
this
.
instantiationService
.
createInstance
(
CommentMenus
,
controller
!
);
this
.
_commentMenus
.
set
(
owner
,
menu
);
return
menu
;
}
...
...
src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts
浏览文件 @
82127d5c
...
...
@@ -44,6 +44,8 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
ContextAwareMenuEntryActionViewItem
}
from
'
vs/platform/actions/browser/menuEntryActionViewItem
'
;
import
{
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
CommentContextKeys
}
from
'
vs/workbench/contrib/comments/common/commentContextKeys
'
;
export
const
COMMENTEDITOR_DECORATION_KEY
=
'
commenteditordecoration
'
;
const
COLLAPSE_ACTION_CLASS
=
'
expand-review-action octicon octicon-chevron-up
'
;
...
...
@@ -76,6 +78,8 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
private
_styleElement
:
HTMLStyleElement
;
private
_formActions
:
HTMLElement
|
null
;
private
_error
:
HTMLElement
;
private
_contextKeyService
:
IContextKeyService
;
private
_threadIsEmpty
:
IContextKey
<
boolean
>
;
public
get
owner
():
string
{
return
this
.
_owner
;
...
...
@@ -109,9 +113,14 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
@
IOpenerService
private
openerService
:
IOpenerService
,
@
IKeybindingService
private
keybindingService
:
IKeybindingService
,
@
INotificationService
private
notificationService
:
INotificationService
,
@
IContextMenuService
private
contextMenuService
:
IContextMenuService
@
IContextMenuService
private
contextMenuService
:
IContextMenuService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
)
{
super
(
editor
,
{
keepEditorSelection
:
true
});
this
.
_contextKeyService
=
contextKeyService
.
createScoped
(
this
.
domNode
);
this
.
_threadIsEmpty
=
CommentContextKeys
.
commentThreadIsEmpty
.
bindTo
(
this
.
_contextKeyService
);
this
.
_threadIsEmpty
.
set
(
!
_commentThread
.
comments
||
!
_commentThread
.
comments
.
length
);
this
.
_resizeObserver
=
null
;
this
.
_isExpanded
=
_commentThread
.
collapsibleState
?
_commentThread
.
collapsibleState
===
modes
.
CommentThreadCollapsibleState
.
Expanded
:
undefined
;
this
.
_globalToDispose
=
[];
...
...
@@ -197,10 +206,6 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
this
.
_bodyElement
=
<
HTMLDivElement
>
dom
.
$
(
'
.body
'
);
container
.
appendChild
(
this
.
_bodyElement
);
dom
.
addDisposableListener
(
this
.
_bodyElement
,
dom
.
EventType
.
FOCUS_IN
,
e
=>
{
this
.
commentService
.
onDidChangeActiveCommentThread
(
this
.
_commentThread
);
});
}
protected
_fillHead
(
container
:
HTMLElement
):
void
{
...
...
@@ -228,7 +233,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
let
secondaryActions
:
IAction
[]
=
[];
if
((
this
.
_commentThread
as
modes
.
CommentThread2
).
commentThreadHandle
!==
undefined
)
{
secondaryActions
=
this
.
_commentMenus
.
getCommentThreadTitleActions
(
this
.
_commentThread
as
modes
.
CommentThread2
);
secondaryActions
=
this
.
_commentMenus
.
getCommentThreadTitleActions
(
this
.
_commentThread
as
modes
.
CommentThread2
,
this
.
_contextKeyService
);
}
this
.
_actionbarWidget
.
push
([...
secondaryActions
,
this
.
_collapseAction
],
{
label
:
false
,
icon
:
true
});
...
...
@@ -243,7 +248,6 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
}
else
{
const
deleteCommand
=
(
this
.
_commentThread
as
modes
.
CommentThread2
).
deleteCommand
;
if
(
deleteCommand
)
{
this
.
commentService
.
onDidChangeActiveCommentThread
(
this
.
_commentThread
);
return
this
.
commandService
.
executeCommand
(
deleteCommand
.
id
,
...(
deleteCommand
.
arguments
||
[]));
}
else
if
(
this
.
_commentEditor
.
getValue
()
===
''
)
{
this
.
dispose
();
...
...
@@ -277,6 +281,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
async
update
(
commentThread
:
modes
.
CommentThread
|
modes
.
CommentThread2
)
{
const
oldCommentsLen
=
this
.
_commentElements
.
length
;
const
newCommentsLen
=
commentThread
.
comments
?
commentThread
.
comments
.
length
:
0
;
this
.
_threadIsEmpty
.
set
(
!
newCommentsLen
);
let
commentElementsToDel
:
CommentNode
[]
=
[];
let
commentElementsToDelIndex
:
number
[]
=
[];
...
...
@@ -475,7 +480,6 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
uri
:
this
.
_commentEditor
.
getModel
()
!
.
uri
,
value
:
this
.
_commentEditor
.
getValue
()
};
this
.
commentService
.
onDidChangeActiveCommentThread
(
this
.
_commentThread
);
}));
this
.
_commentThreadDisposables
.
push
(
this
.
_commentEditor
.
getModel
()
!
.
onDidChangeContent
(()
=>
{
...
...
@@ -687,7 +691,6 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
uri
:
this
.
_commentEditor
.
getModel
()
!
.
uri
,
value
:
this
.
_commentEditor
.
getValue
()
};
this
.
commentService
.
onDidChangeActiveCommentThread
(
this
.
_commentThread
);
await
this
.
commandService
.
executeCommand
(
acceptInputCommand
.
id
,
...(
acceptInputCommand
.
arguments
||
[]));
}));
...
...
@@ -712,13 +715,12 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
uri
:
this
.
_commentEditor
.
getModel
()
!
.
uri
,
value
:
this
.
_commentEditor
.
getValue
()
};
this
.
commentService
.
onDidChangeActiveCommentThread
(
this
.
_commentThread
);
await
this
.
commandService
.
executeCommand
(
command
.
id
,
...(
command
.
arguments
||
[]));
}));
});
}
let
actions
=
this
.
_commentMenus
.
getCommentThreadActions
(
commentThread
);
let
actions
=
this
.
_commentMenus
.
getCommentThreadActions
(
commentThread
,
this
.
_contextKeyService
);
actions
.
forEach
(
action
=>
{
const
button
=
new
Button
(
container
);
...
...
@@ -783,7 +785,6 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
uri
:
this
.
_commentEditor
.
getModel
()
!
.
uri
,
value
:
this
.
_commentEditor
.
getValue
()
};
this
.
commentService
.
onDidChangeActiveCommentThread
(
this
.
_commentThread
);
let
commandId
=
commentThread
.
acceptInputCommand
.
id
;
let
args
=
commentThread
.
acceptInputCommand
.
arguments
||
[];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录