Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b64d2985
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,发现更多精彩内容 >>
提交
b64d2985
编写于
4月 24, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
notebook respect editor association
上级
7f5bada0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
4 deletion
+46
-4
src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts
...rkbench/contrib/notebook/browser/notebook.contribution.ts
+41
-4
src/vs/workbench/contrib/notebook/browser/notebookService.ts
src/vs/workbench/contrib/notebook/browser/notebookService.ts
+5
-0
未找到文件。
src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts
浏览文件 @
b64d2985
...
...
@@ -31,6 +31,10 @@ import { CellKind, CellUri } from 'vs/workbench/contrib/notebook/common/notebook
import
{
NotebookProviderInfo
}
from
'
vs/workbench/contrib/notebook/common/notebookProvider
'
;
import
{
IEditorGroup
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
IEditorService
,
IOpenEditorOverride
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
CustomEditorsAssociations
,
customEditorsAssociationsSettingId
}
from
'
vs/workbench/services/editor/common/editorAssociationsSetting
'
;
import
{
coalesce
,
distinct
}
from
'
vs/base/common/arrays
'
;
import
{
CustomEditorInfo
}
from
'
vs/workbench/contrib/customEditor/common/customEditor
'
;
// Editor Contribution
...
...
@@ -96,7 +100,8 @@ export class NotebookContribution implements IWorkbenchContribution {
constructor
(
@
IEditorService
private
readonly
editorService
:
IEditorService
,
@
INotebookService
private
readonly
notebookService
:
INotebookService
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
@
IConfigurationService
private
readonly
configurationService
:
IConfigurationService
)
{
this
.
editorService
.
overrideOpenEditor
({
...
...
@@ -106,9 +111,12 @@ export class NotebookContribution implements IWorkbenchContribution {
return
[];
}
const
infos
=
notebookService
.
getContributedNotebookProviders
(
resource
);
const
associatedEditors
=
distinct
([
...
this
.
getUserAssociatedNotebookEditors
(
resource
),
...
this
.
getContributedEditors
(
resource
)
],
editor
=>
editor
.
id
);
return
info
s
.
map
(
info
=>
{
return
associatedEditor
s
.
map
(
info
=>
{
return
{
label
:
info
.
displayName
,
id
:
info
.
id
,
...
...
@@ -128,12 +136,41 @@ export class NotebookContribution implements IWorkbenchContribution {
});
}
getUserAssociatedEditors
(
resource
:
URI
)
{
const
rawAssociations
=
this
.
configurationService
.
getValue
<
CustomEditorsAssociations
>
(
customEditorsAssociationsSettingId
)
||
[];
return
coalesce
(
rawAssociations
.
filter
(
association
=>
CustomEditorInfo
.
selectorMatches
(
association
,
resource
)));
}
getUserAssociatedNotebookEditors
(
resource
:
URI
)
{
const
rawAssociations
=
this
.
configurationService
.
getValue
<
CustomEditorsAssociations
>
(
customEditorsAssociationsSettingId
)
||
[];
return
coalesce
(
rawAssociations
.
filter
(
association
=>
CustomEditorInfo
.
selectorMatches
(
association
,
resource
))
.
map
(
association
=>
this
.
notebookService
.
getContributedNotebookProvider
(
association
.
viewType
)));
}
getContributedEditors
(
resource
:
URI
)
{
return
this
.
notebookService
.
getContributedNotebookProviders
(
resource
);
}
private
onEditorOpening
(
originalInput
:
IEditorInput
,
options
:
IEditorOptions
|
ITextEditorOptions
|
undefined
,
group
:
IEditorGroup
,
id
:
string
|
undefined
):
IOpenEditorOverride
|
undefined
{
let
resource
=
originalInput
.
resource
;
if
(
!
resource
)
{
return
undefined
;
}
if
(
id
===
undefined
)
{
const
userAssociatedEditors
=
this
.
getUserAssociatedEditors
(
resource
);
const
notebookEditor
=
userAssociatedEditors
.
filter
(
association
=>
this
.
notebookService
.
getContributedNotebookProvider
(
association
.
viewType
));
if
(
userAssociatedEditors
.
length
&&
!
notebookEditor
.
length
)
{
// user pick a non-notebook editor for this resource
return
undefined
;
}
}
if
(
this
.
_resourceMapping
.
has
(
resource
))
{
const
input
=
this
.
_resourceMapping
.
get
(
resource
);
...
...
@@ -145,7 +182,7 @@ export class NotebookContribution implements IWorkbenchContribution {
let
info
:
NotebookProviderInfo
|
undefined
;
const
data
=
CellUri
.
parse
(
resource
);
if
(
data
)
{
const
infos
=
this
.
notebookService
.
getContributedNotebookProvide
rs
(
data
.
notebook
);
const
infos
=
this
.
getContributedEdito
rs
(
data
.
notebook
);
if
(
infos
.
length
)
{
const
info
=
id
===
undefined
?
infos
[
0
]
:
(
infos
.
find
(
info
=>
info
.
id
===
id
)
||
infos
[
0
]);
...
...
src/vs/workbench/contrib/notebook/browser/notebookService.ts
浏览文件 @
b64d2985
...
...
@@ -49,6 +49,7 @@ export interface INotebookService {
executeNotebookCell
(
viewType
:
string
,
uri
:
URI
,
handle
:
number
,
token
:
CancellationToken
):
Promise
<
void
>
;
getContributedNotebookProviders
(
resource
:
URI
):
readonly
NotebookProviderInfo
[];
getContributedNotebookProvider
(
viewType
:
string
):
NotebookProviderInfo
|
undefined
;
getNotebookProviderResourceRoots
():
URI
[];
destoryNotebookDocument
(
viewType
:
string
,
notebook
:
INotebookTextModel
):
void
;
updateActiveNotebookDocument
(
viewType
:
string
,
resource
:
URI
):
void
;
...
...
@@ -273,6 +274,10 @@ export class NotebookService extends Disposable implements INotebookService, ICu
return
this
.
notebookProviderInfoStore
.
getContributedNotebook
(
resource
);
}
getContributedNotebookProvider
(
viewType
:
string
):
NotebookProviderInfo
|
undefined
{
return
this
.
notebookProviderInfoStore
.
get
(
viewType
);
}
getContributedNotebookOutputRenderers
(
mimeType
:
string
):
readonly
NotebookOutputRendererInfo
[]
{
return
this
.
notebookRenderersInfoStore
.
getContributedRenderer
(
mimeType
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录