Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
260d2992
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,体验更适合开发者的 AI 搜索 >>
提交
260d2992
编写于
4月 10, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prototyping declarative action contribution for threads
上级
bd83b6da
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
65 addition
and
26 deletion
+65
-26
extensions/git-extended/src/commentsProvider.ts
extensions/git-extended/src/commentsProvider.ts
+19
-2
extensions/markdown-language-features/package.json
extensions/markdown-language-features/package.json
+0
-5
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+2
-0
src/vs/editor/contrib/review/review.ts
src/vs/editor/contrib/review/review.ts
+31
-13
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+2
-0
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+2
-0
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+1
-1
src/vs/workbench/api/node/extHostComments.ts
src/vs/workbench/api/node/extHostComments.ts
+8
-5
未找到文件。
extensions/git-extended/src/commentsProvider.ts
浏览文件 @
260d2992
...
...
@@ -8,6 +8,14 @@ import * as vscode from 'vscode';
import
*
as
_
from
'
lodash
'
;
import
{
Comment
}
from
'
./common/models/comment
'
;
class
PostCommentCommand
{
public
static
readonly
id
=
'
pr.postComment
'
;
public
static
run
(
id
:
string
,
text
:
string
)
{
vscode
.
window
.
showInformationMessage
(
`posty!
${
text
}
`
);
}
}
export
interface
ICommentsProvider
{
provideComments
(
uri
:
vscode
.
Uri
):
Promise
<
Comment
[]
>
;
}
...
...
@@ -20,6 +28,8 @@ export class CommentsProvider implements vscode.CommentProvider {
this
.
providers
=
new
Map
<
number
,
ICommentsProvider
>
();
this
.
_id
=
0
;
vscode
.
workspace
.
registerCommentProvider
(
this
);
vscode
.
commands
.
registerCommand
(
PostCommentCommand
.
id
,
PostCommentCommand
.
run
);
}
registerCommentProvider
(
provider
:
ICommentsProvider
):
number
{
...
...
@@ -51,7 +61,7 @@ export class CommentsProvider implements vscode.CommentProvider {
}
let
sections
=
_
.
groupBy
(
matchingComments
,
comment
=>
comment
.
position
);
let
ret
=
[];
let
ret
:
vscode
.
CommentThread
[]
=
[];
for
(
let
i
in
sections
)
{
let
comments
=
sections
[
i
];
...
...
@@ -63,6 +73,7 @@ export class CommentsProvider implements vscode.CommentProvider {
const
newCommentEndPos
=
new
vscode
.
Position
(
comment
.
diff_hunk_range
.
start
+
comment
.
diff_hunk_range
.
length
-
1
-
1
,
0
);
ret
.
push
({
threadId
:
comment
.
id
,
range
,
newCommentRange
:
new
vscode
.
Range
(
newCommentStartPos
,
newCommentEndPos
),
comments
:
comments
.
map
(
comment
=>
{
...
...
@@ -71,7 +82,13 @@ export class CommentsProvider implements vscode.CommentProvider {
userName
:
comment
.
user
.
login
,
gravatar
:
comment
.
user
.
avatar_url
};
})
}),
actions
:
[
{
command
:
PostCommentCommand
.
id
,
title
:
'
Post
'
}
]
});
}
...
...
extensions/markdown-language-features/package.json
浏览文件 @
260d2992
...
...
@@ -27,11 +27,6 @@
],
"contributes"
:
{
"commands"
:
[
{
"command"
:
"unicorn"
,
"title"
:
"🦄 unicorn"
,
"category"
:
"Markdown"
},
{
"command"
:
"markdown.showPreview"
,
"title"
:
"%markdown.preview.title%"
,
...
...
src/vs/editor/common/modes.ts
浏览文件 @
260d2992
...
...
@@ -939,9 +939,11 @@ export interface Command {
export
interface
CommentThread
{
readonly
threadId
:
string
;
readonly
range
:
IRange
;
readonly
newCommentRange
:
IRange
;
readonly
comments
:
Comment
[];
readonly
actions
:
Command
[];
}
export
interface
Comment
{
...
...
src/vs/editor/contrib/review/review.ts
浏览文件 @
260d2992
...
...
@@ -28,6 +28,7 @@ import { registerThemingParticipant, ITheme, IThemeService } from 'vs/platform/t
import
{
peekViewEditorBackground
,
peekViewBorder
,
}
from
'
vs/editor/contrib/referenceSearch/referencesWidget
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
IMarginData
}
from
'
vs/editor/browser/controller/mouseTarget
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
export
const
ctxReviewPanelVisible
=
new
RawContextKey
<
boolean
>
(
'
reviewPanelVisible
'
,
false
);
export
const
ID
=
'
editor.contrib.review
'
;
...
...
@@ -72,7 +73,10 @@ export class ReviewZoneWidget extends ZoneWidget {
private
_resizeObserver
:
any
;
private
_comments
:
modes
.
Comment
[];
constructor
(@
IThemeService
private
themeService
:
IThemeService
,
constructor
(
private
readonly
themeService
:
IThemeService
,
private
readonly
commandService
:
ICommandService
,
editor
:
ICodeEditor
,
options
:
IOptions
=
{},
comments
:
modes
.
Comment
[])
{
super
(
editor
,
options
);
this
.
_resizeObserver
=
null
;
...
...
@@ -125,7 +129,8 @@ export class ReviewZoneWidget extends ZoneWidget {
}
display
(
comments
:
modes
.
Comment
[],
lineNumber
:
number
)
{
display
(
commentThread
:
modes
.
CommentThread
,
lineNumber
:
number
)
{
const
comments
=
commentThread
.
comments
;
this
.
show
({
lineNumber
:
lineNumber
,
column
:
1
},
2
);
this
.
_bodyElement
.
style
.
display
=
'
none
'
;
...
...
@@ -161,7 +166,19 @@ export class ReviewZoneWidget extends ZoneWidget {
body
.
appendChild
(
renderMarkdown
(
md
));
this
.
_bodyElement
.
appendChild
(
singleCommentContainer
);
}
// this._domNode.appendChild(document.createElement('textarea'));
const
textArea
=
document
.
createElement
(
'
textarea
'
);
this
.
_bodyElement
.
appendChild
(
textArea
);
for
(
const
action
of
commentThread
.
actions
)
{
const
button
=
document
.
createElement
(
'
button
'
);
button
.
onclick
=
()
=>
{
this
.
commandService
.
executeCommand
(
action
.
id
,
commentThread
.
threadId
,
textArea
.
value
);
};
button
.
textContent
=
action
.
title
;
this
.
_bodyElement
.
appendChild
(
button
);
}
this
.
_resizeObserver
=
new
ResizeObserver
(
entries
=>
{
if
(
entries
[
0
].
target
===
this
.
_bodyElement
)
{
const
lineHeight
=
this
.
editor
.
getConfiguration
().
lineHeight
;
...
...
@@ -207,7 +224,8 @@ export class ReviewController implements IEditorContribution {
constructor
(
editor
:
ICodeEditor
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IThemeService
private
themeService
:
IThemeService
@
IThemeService
private
themeService
:
IThemeService
,
@
ICommandService
private
commandService
:
ICommandService
,
)
{
this
.
editor
=
editor
;
this
.
globalToDispose
=
[];
...
...
@@ -307,11 +325,11 @@ export class ReviewController implements IEditorContribution {
return
;
}
let
comments
=
this
.
getComments
(
lineNumber
);
if
(
comments
&&
comments
.
length
)
{
let
thread
=
this
.
getCommentThread
(
lineNumber
);
if
(
thread
&&
thread
.
comments
.
length
)
{
this
.
_reviewPanelVisible
.
set
(
true
);
this
.
_zoneWidget
=
new
ReviewZoneWidget
(
this
.
themeService
,
this
.
editor
,
{},
comments
);
this
.
_zoneWidget
.
display
(
this
.
getComment
s
(
lineNumber
),
lineNumber
);
this
.
_zoneWidget
=
new
ReviewZoneWidget
(
this
.
themeService
,
this
.
commandService
,
this
.
editor
,
{},
thread
.
comments
);
this
.
_zoneWidget
.
display
(
this
.
getComment
Thread
(
lineNumber
),
lineNumber
);
}
}
...
...
@@ -371,14 +389,14 @@ export class ReviewController implements IEditorContribution {
return
true
;
}
getComment
s
(
line
:
number
):
modes
.
Comment
[]
{
getComment
Thread
(
line
:
number
):
modes
.
CommentThread
|
undefined
{
for
(
let
i
=
0
;
i
<
this
.
_commentThreads
.
length
;
i
++
)
{
if
(
this
.
_commentThreads
[
i
].
range
.
startLineNumber
===
line
)
{
return
this
.
_commentThreads
[
i
]
.
comments
;
return
this
.
_commentThreads
[
i
];
}
}
return
[]
;
return
undefined
;
}
setComments
(
commentThreads
:
modes
.
CommentThread
[]):
void
{
...
...
@@ -396,8 +414,8 @@ export class ReviewController implements IEditorContribution {
});
this
.
_commentThreads
.
forEach
(
thread
=>
{
let
zoneWidget
=
new
ReviewZoneWidget
(
this
.
themeService
,
this
.
editor
,
{},
thread
.
comments
);
zoneWidget
.
display
(
this
.
getComment
s
(
thread
.
range
.
startLineNumber
),
thread
.
range
.
startLineNumber
);
let
zoneWidget
=
new
ReviewZoneWidget
(
this
.
themeService
,
this
.
commandService
,
this
.
editor
,
{},
thread
.
comments
);
zoneWidget
.
display
(
this
.
getComment
Thread
(
thread
.
range
.
startLineNumber
),
thread
.
range
.
startLineNumber
);
this
.
_zoneWidgets
.
push
(
zoneWidget
);
});
...
...
src/vs/monaco.d.ts
浏览文件 @
260d2992
...
...
@@ -5029,9 +5029,11 @@ declare namespace monaco.languages {
}
export
interface
CommentThread
{
readonly
threadId
:
string
;
readonly
range
:
IRange
;
readonly
newCommentRange
:
IRange
;
readonly
comments
:
Comment
[];
readonly
actions
:
Command
[];
}
export
interface
Comment
{
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
260d2992
...
...
@@ -771,9 +771,11 @@ declare module 'vscode' {
//#endregion
interface
CommentThread
{
threadId
:
string
;
range
:
Range
;
newCommentRange
:
Range
;
comments
:
Comment
[];
actions
?:
Command
[];
}
interface
Comment
{
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
260d2992
...
...
@@ -120,7 +120,7 @@ export function createApiFactory(
const
extHostWindow
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostWindow
,
new
ExtHostWindow
(
rpcProtocol
));
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostExtensionService
,
extensionService
);
const
extHostProgress
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostProgress
,
new
ExtHostProgress
(
rpcProtocol
.
getProxy
(
MainContext
.
MainThreadProgress
)));
const
exthostCommentProviders
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostComments
,
new
ExtHostComments
(
rpcProtocol
,
extHostDocuments
));
const
exthostCommentProviders
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostComments
,
new
ExtHostComments
(
rpcProtocol
,
extHost
Commands
.
converter
,
extHost
Documents
));
// Check that no named customers are missing
const
expected
:
ProxyIdentifier
<
any
>
[]
=
Object
.
keys
(
ExtHostContext
).
map
((
key
)
=>
ExtHostContext
[
key
]);
...
...
src/vs/workbench/api/node/extHostComments.ts
浏览文件 @
260d2992
...
...
@@ -11,11 +11,11 @@ import URI, { UriComponents } from 'vs/base/common/uri';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
ExtHostDocuments
}
from
'
vs/workbench/api/node/extHostDocuments
'
;
import
*
as
extHostTypeConverter
from
'
vs/workbench/api/node/extHostTypeConverters
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
flatten
}
from
'
../../../base/common/arrays
'
;
import
{
ExtHostCommentsShape
,
IMainContext
,
MainContext
,
MainThreadCommentsShape
}
from
'
./extHost.protocol
'
;
import
*
as
extHostTypeConverter
from
'
vs/workbench/api/node/extHostTypeConverters
'
;
import
{
CommandsConverter
}
from
'
./extHostCommands
'
;
export
class
ExtHostComments
implements
ExtHostCommentsShape
{
...
...
@@ -27,6 +27,7 @@ export class ExtHostComments implements ExtHostCommentsShape {
constructor
(
mainContext
:
IMainContext
,
private
readonly
_commandsConverter
:
CommandsConverter
,
private
readonly
_documents
:
ExtHostDocuments
,
)
{
this
.
_proxy
=
mainContext
.
getProxy
(
MainContext
.
MainThreadComments
);
...
...
@@ -58,15 +59,17 @@ export class ExtHostComments implements ExtHostCommentsShape {
return
TPromise
.
join
(
allProviderResults
);
})
.
then
(
flatten
)
.
then
(
comments
=>
comments
.
map
(
convertCommentThread
));
.
then
(
comments
=>
comments
.
map
(
x
=>
convertCommentThread
(
x
,
this
.
_commandsConverter
)
));
}
}
function
convertCommentThread
(
vscodeCommentThread
:
vscode
.
CommentThread
):
modes
.
CommentThread
{
function
convertCommentThread
(
vscodeCommentThread
:
vscode
.
CommentThread
,
commandsConverter
:
CommandsConverter
):
modes
.
CommentThread
{
return
{
threadId
:
vscodeCommentThread
.
threadId
,
range
:
extHostTypeConverter
.
fromRange
(
vscodeCommentThread
.
range
),
newCommentRange
:
extHostTypeConverter
.
fromRange
(
vscodeCommentThread
.
newCommentRange
),
comments
:
vscodeCommentThread
.
comments
.
map
(
convertComment
)
comments
:
vscodeCommentThread
.
comments
.
map
(
convertComment
),
actions
:
vscodeCommentThread
.
actions
.
map
(
commandsConverter
.
toInternal
)
};
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录