Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
9623b344
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,发现更多精彩内容 >>
未验证
提交
9623b344
编写于
12月 13, 2018
作者:
R
Rachel Macfarlane
提交者:
GitHub
12月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add setting to control when comments panel opens (#64941)
上级
21b0059b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
82 addition
and
5 deletion
+82
-5
src/vs/workbench/api/electron-browser/mainThreadComments.ts
src/vs/workbench/api/electron-browser/mainThreadComments.ts
+56
-5
src/vs/workbench/parts/comments/electron-browser/comments.contribution.ts
.../parts/comments/electron-browser/comments.contribution.ts
+21
-0
src/vs/workbench/parts/preferences/browser/settingsLayout.ts
src/vs/workbench/parts/preferences/browser/settingsLayout.ts
+5
-0
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadComments.ts
浏览文件 @
9623b344
...
...
@@ -17,6 +17,8 @@ import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
generateUuid
}
from
'
vs/base/common/uuid
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ICommentsConfiguration
}
from
'
vs/workbench/parts/comments/electron-browser/comments.contribution
'
;
export
class
MainThreadDocumentCommentProvider
implements
modes
.
DocumentCommentProvider
{
private
_proxy
:
ExtHostCommentsShape
;
...
...
@@ -72,18 +74,18 @@ export class MainThreadComments extends Disposable implements MainThreadComments
private
_documentProviders
=
new
Map
<
number
,
IDisposable
>
();
private
_workspaceProviders
=
new
Map
<
number
,
IDisposable
>
();
private
_handlers
=
new
Map
<
number
,
string
>
();
private
_
firstSessionStart
:
boolean
;
private
_
openPanelListener
:
IDisposable
|
null
;
constructor
(
extHostContext
:
IExtHostContext
,
@
IEditorService
private
_editorService
:
IEditorService
,
@
ICommentService
private
_commentService
:
ICommentService
,
@
IPanelService
private
_panelService
:
IPanelService
,
@
ITelemetryService
private
_telemetryService
:
ITelemetryService
@
ITelemetryService
private
_telemetryService
:
ITelemetryService
,
@
IConfigurationService
private
_configurationService
:
IConfigurationService
)
{
super
();
this
.
_disposables
=
[];
this
.
_firstSessionStart
=
true
;
this
.
_proxy
=
extHostContext
.
getProxy
(
ExtHostContext
.
ExtHostComments
);
}
...
...
@@ -97,19 +99,62 @@ export class MainThreadComments extends Disposable implements MainThreadComments
this
.
_commentService
.
registerDataProvider
(
providerId
,
handler
);
}
/**
* If the comments panel has never been opened, the constructor for it has not yet run so it has
* no listeners for comment threads being set or updated. Listen for the panel opening for the
* first time and send it comments then.
*/
private
registerOpenPanelListener
(
commentsPanelAlreadyConstructed
:
boolean
)
{
if
(
!
commentsPanelAlreadyConstructed
&&
!
this
.
_openPanelListener
)
{
this
.
_openPanelListener
=
this
.
_panelService
.
onDidPanelOpen
(
e
=>
{
if
(
e
.
panel
.
getId
()
===
COMMENTS_PANEL_ID
)
{
keys
(
this
.
_workspaceProviders
).
forEach
(
handle
=>
{
this
.
_proxy
.
$provideWorkspaceComments
(
handle
).
then
(
commentThreads
=>
{
if
(
commentThreads
)
{
const
providerId
=
this
.
_handlers
.
get
(
handle
);
this
.
_commentService
.
setWorkspaceComments
(
providerId
,
commentThreads
);
}
});
});
this
.
_openPanelListener
.
dispose
();
this
.
_openPanelListener
=
null
;
}
});
}
}
$registerWorkspaceCommentProvider
(
handle
:
number
,
extensionId
:
string
):
void
{
this
.
_workspaceProviders
.
set
(
handle
,
undefined
);
const
providerId
=
generateUuid
();
this
.
_handlers
.
set
(
handle
,
providerId
);
const
commentsPanelAlreadyConstructed
=
this
.
_panelService
.
getPanels
().
some
(
panel
=>
panel
.
id
===
COMMENTS_PANEL_ID
);
this
.
_panelService
.
setPanelEnablement
(
COMMENTS_PANEL_ID
,
true
);
if
(
this
.
_firstSessionStart
)
{
const
openPanel
=
this
.
_configurationService
.
getValue
<
ICommentsConfiguration
>
(
'
comments
'
).
openPanel
;
if
(
openPanel
===
'
neverOpen
'
)
{
this
.
registerOpenPanelListener
(
commentsPanelAlreadyConstructed
);
}
if
(
openPanel
===
'
openOnSessionStart
'
)
{
this
.
_panelService
.
openPanel
(
COMMENTS_PANEL_ID
);
this
.
_firstSessionStart
=
false
;
}
this
.
_proxy
.
$provideWorkspaceComments
(
handle
).
then
(
commentThreads
=>
{
if
(
commentThreads
)
{
if
(
openPanel
===
'
openOnSessionStartWithComments
'
&&
commentThreads
.
length
)
{
if
(
commentThreads
.
length
)
{
this
.
_panelService
.
openPanel
(
COMMENTS_PANEL_ID
);
}
else
{
this
.
registerOpenPanelListener
(
commentsPanelAlreadyConstructed
);
}
}
this
.
_commentService
.
setWorkspaceComments
(
providerId
,
commentThreads
);
}
});
...
...
@@ -135,7 +180,13 @@ export class MainThreadComments extends Disposable implements MainThreadComments
this
.
_workspaceProviders
.
delete
(
handle
);
if
(
this
.
_workspaceProviders
.
size
===
0
)
{
this
.
_panelService
.
setPanelEnablement
(
COMMENTS_PANEL_ID
,
false
);
if
(
this
.
_openPanelListener
)
{
this
.
_openPanelListener
.
dispose
();
this
.
_openPanelListener
=
null
;
}
}
const
handlerId
=
this
.
_handlers
.
get
(
handle
);
this
.
_commentService
.
removeWorkspaceComments
(
handlerId
);
this
.
_handlers
.
delete
(
handle
);
...
...
src/vs/workbench/parts/comments/electron-browser/comments.contribution.ts
浏览文件 @
9623b344
...
...
@@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
nls
from
'
vs/nls
'
;
import
{
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
...
...
@@ -12,6 +13,11 @@ import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import
{
COMMENTS_PANEL_ID
,
COMMENTS_PANEL_TITLE
,
CommentsPanel
}
from
'
./commentsPanel
'
;
import
'
vs/workbench/parts/comments/electron-browser/commentsEditorContribution
'
;
import
{
ICommentService
,
CommentService
}
from
'
vs/workbench/parts/comments/electron-browser/commentService
'
;
import
{
IConfigurationRegistry
,
Extensions
as
ConfigurationExtensions
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
export
interface
ICommentsConfiguration
{
openPanel
:
'
neverOpen
'
|
'
openOnSessionStart
'
|
'
openOnSessionStartWithComments
'
;
}
export
class
CommentPanelVisibilityUpdater
implements
IWorkbenchContribution
{
...
...
@@ -35,6 +41,21 @@ Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescri
10
));
Registry
.
as
<
IConfigurationRegistry
>
(
ConfigurationExtensions
.
Configuration
).
registerConfiguration
({
id
:
'
comments
'
,
order
:
20
,
title
:
nls
.
localize
(
'
commentsConfigurationTitle
'
,
"
Comments
"
),
type
:
'
object
'
,
properties
:
{
'
comments.openPanel
'
:
{
enum
:
[
'
neverOpen
'
,
'
openOnSessionStart
'
,
'
openOnSessionStartWithComments
'
],
default
:
'
openOnSessionStartWithComments
'
,
description
:
nls
.
localize
(
'
openComments
'
,
"
Controls when the comments panel should open.
"
)
}
}
});
// Register view location updater
Registry
.
as
<
IWorkbenchContributionsRegistry
>
(
WorkbenchExtensions
.
Workbench
).
registerWorkbenchContribution
(
CommentPanelVisibilityUpdater
,
LifecyclePhase
.
Starting
);
...
...
src/vs/workbench/parts/preferences/browser/settingsLayout.ts
浏览文件 @
9623b344
...
...
@@ -154,6 +154,11 @@ export const tocData: ITOCEntry = {
id
:
'
features/problems
'
,
label
:
localize
(
'
problems
'
,
"
Problems
"
),
settings
:
[
'
problems.*
'
]
},
{
id
:
'
features/comments
'
,
label
:
localize
(
'
comments
'
,
"
Comments
"
),
settings
:
[
'
comments.*
'
]
}
]
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录