Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ff5e7462
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,发现更多精彩内容 >>
提交
ff5e7462
编写于
2月 20, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
activate extension by notebook view type
上级
62f68fec
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
40 addition
and
32 deletion
+40
-32
extensions/notebook-test/package.json
extensions/notebook-test/package.json
+2
-1
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
+1
-1
src/vs/workbench/contrib/notebook/browser/notebookEditorInput.ts
...workbench/contrib/notebook/browser/notebookEditorInput.ts
+11
-28
src/vs/workbench/contrib/notebook/browser/notebookService.ts
src/vs/workbench/contrib/notebook/browser/notebookService.ts
+25
-1
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+1
-1
未找到文件。
extensions/notebook-test/package.json
浏览文件 @
ff5e7462
...
...
@@ -19,7 +19,8 @@
"Other"
],
"activationEvents"
:
[
"*"
"onNotebookEditor:jupyter"
,
"onNotebookEditor:jupytertest"
],
"contributes"
:
{
"commands"
:
[
...
...
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
浏览文件 @
ff5e7462
...
...
@@ -288,7 +288,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
return
input
.
resolve
();
})
.
then
(
async
model
=>
{
if
(
this
.
model
!==
undefined
&&
this
.
model
.
textModel
===
model
.
textM
odel
&&
this
.
webview
!==
null
)
{
if
(
this
.
model
!==
undefined
&&
this
.
model
===
m
odel
&&
this
.
webview
!==
null
)
{
return
;
}
...
...
src/vs/workbench/contrib/notebook/browser/notebookEditorInput.ts
浏览文件 @
ff5e7462
...
...
@@ -4,8 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import
{
EditorInput
,
EditorModel
,
IEditorInput
,
GroupIdentifier
,
ISaveOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
INotebookService
}
from
'
vs/workbench/contrib/notebook/browser/notebookService
'
;
import
{
INotebook
,
ICell
,
NotebookCellsSplice
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
...
...
@@ -21,8 +19,7 @@ export class NotebookEditorModel extends EditorModel {
get
onDidChangeCells
():
Event
<
NotebookCellsSplice
[]
>
{
return
this
.
_onDidChangeCells
.
event
;
}
constructor
(
public
readonly
textModel
:
ITextModel
,
private
_notebook
:
INotebook
|
undefined
private
_notebook
:
INotebook
)
{
super
();
...
...
@@ -44,14 +41,7 @@ export class NotebookEditorModel extends EditorModel {
}
getNotebook
():
INotebook
{
if
(
this
.
_notebook
)
{
return
this
.
_notebook
;
}
// TODO, remove file based notebook from core
let
content
=
this
.
textModel
.
getValue
();
this
.
_notebook
=
JSON
.
parse
(
content
);
return
this
.
_notebook
!
;
return
this
.
_notebook
;
}
insertCell
(
cell
:
ICell
,
index
:
number
)
{
...
...
@@ -100,8 +90,7 @@ export class NotebookEditorInput extends EditorInput {
public
resource
:
URI
,
public
name
:
string
,
public
readonly
viewType
:
string
|
undefined
,
@
INotebookService
private
readonly
notebookService
:
INotebookService
,
@
ITextModelService
private
readonly
textModelResolverService
:
ITextModelService
@
INotebookService
private
readonly
notebookService
:
INotebookService
)
{
super
();
}
...
...
@@ -128,21 +117,15 @@ export class NotebookEditorInput extends EditorInput {
return
undefined
;
}
resolve
():
Promise
<
NotebookEditorModel
>
{
async
resolve
():
Promise
<
NotebookEditorModel
>
{
if
(
!
this
.
promise
)
{
this
.
promise
=
this
.
textModelResolverService
.
createModelReference
(
this
.
resource
)
.
then
(
async
ref
=>
{
const
textModel
=
ref
.
object
.
textEditorModel
;
let
notebook
:
INotebook
|
undefined
=
undefined
;
if
(
this
.
viewType
!==
undefined
)
{
notebook
=
await
this
.
notebookService
.
resolveNotebook
(
this
.
viewType
,
this
.
resource
);
}
this
.
textModel
=
new
NotebookEditorModel
(
textModel
,
notebook
);
this
.
textModel
.
onDidChangeDirty
(()
=>
this
.
_onDidChangeDirty
.
fire
());
return
this
.
textModel
;
});
await
this
.
notebookService
.
canResolve
(
this
.
viewType
!
);
this
.
promise
=
this
.
notebookService
.
resolveNotebook
(
this
.
viewType
!
,
this
.
resource
).
then
(
notebook
=>
{
this
.
textModel
=
new
NotebookEditorModel
(
notebook
!
);
this
.
textModel
.
onDidChangeDirty
(()
=>
this
.
_onDidChangeDirty
.
fire
());
return
this
.
textModel
;
});
}
return
this
.
promise
;
...
...
src/vs/workbench/contrib/notebook/browser/notebookService.ts
浏览文件 @
ff5e7462
...
...
@@ -11,6 +11,7 @@ import { NotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/noteb
import
{
NotebookExtensionDescription
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
INotebook
,
ICell
,
INotebookMimeTypeSelector
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
function
MODEL_ID
(
resource
:
URI
):
string
{
return
resource
.
toString
();
...
...
@@ -30,6 +31,7 @@ export interface IMainNotebookController {
export
interface
INotebookService
{
_serviceBrand
:
undefined
;
canResolve
(
viewType
:
string
):
Promise
<
void
>
;
onDidChangeActiveEditor
:
Event
<
{
viewType
:
string
,
uri
:
URI
}
>
;
registerNotebookController
(
viewType
:
string
,
extensionData
:
NotebookExtensionDescription
,
controller
:
IMainNotebookController
):
void
;
unregisterNotebookProvider
(
viewType
:
string
):
void
;
...
...
@@ -97,8 +99,11 @@ export class NotebookService extends Disposable implements INotebookService {
private
readonly
_models
:
{
[
modelId
:
string
]:
ModelData
;
};
private
_onDidChangeActiveEditor
=
new
Emitter
<
{
viewType
:
string
,
uri
:
URI
}
>
();
onDidChangeActiveEditor
:
Event
<
{
viewType
:
string
,
uri
:
URI
}
>
=
this
.
_onDidChangeActiveEditor
.
event
;
private
_resolvePool
=
new
Map
<
string
,
()
=>
void
>
();
constructor
()
{
constructor
(
@
IExtensionService
private
readonly
extensionService
:
IExtensionService
)
{
super
();
this
.
_models
=
{};
...
...
@@ -119,8 +124,27 @@ export class NotebookService extends Disposable implements INotebookService {
}
async
canResolve
(
viewType
:
string
):
Promise
<
void
>
{
if
(
this
.
_notebookProviders
.
has
(
viewType
))
{
return
;
}
this
.
extensionService
.
activateByEvent
(
`onNotebookEditor:
${
viewType
}
`
);
let
resolve
:
()
=>
void
;
const
promise
=
new
Promise
<
void
>
(
r
=>
{
resolve
=
r
;
});
this
.
_resolvePool
.
set
(
viewType
,
resolve
!
);
return
promise
;
}
registerNotebookController
(
viewType
:
string
,
extensionData
:
NotebookExtensionDescription
,
controller
:
IMainNotebookController
)
{
this
.
_notebookProviders
.
set
(
viewType
,
{
extensionData
,
controller
});
let
resolve
=
this
.
_resolvePool
.
get
(
viewType
);
if
(
resolve
)
{
resolve
();
this
.
_resolvePool
.
delete
(
viewType
);
}
}
unregisterNotebookProvider
(
viewType
:
string
):
void
{
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
ff5e7462
...
...
@@ -5,7 +5,7 @@
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IResourceInput
,
ITextEditorOptions
,
IEditorOptions
,
EditorActivation
}
from
'
vs/platform/editor/common/editor
'
;
import
{
SideBySideEditor
as
SideBySideEditorChoice
,
IEditorInput
,
IEditor
,
GroupIdentifier
,
IFileEditorInput
,
IUntitledTextResourceInput
,
IResourceDiffInput
,
IResourceSideBySideInput
,
IEditorInputFactoryRegistry
,
Extensions
as
EditorExtensions
,
IFileInputFactory
,
EditorInput
,
SideBySideEditorInput
,
IEditorInputWithOptions
,
isEditorInputWithOptions
,
EditorOptions
,
TextEditorOptions
,
IEditorIdentifier
,
IEditorCloseEvent
,
ITextEditor
,
ITextDiffEditor
,
ITextSideBySideEditor
,
IRevertOptions
,
SaveReason
,
EditorsOrder
,
isTextEditor
,
ICompositeCodeEditor
,
IWorkbenchEditorConfiguration
,
toResource
}
from
'
vs/workbench/common/editor
'
;
import
{
SideBySideEditor
as
SideBySideEditorChoice
,
IEditorInput
,
IEditor
,
GroupIdentifier
,
IFileEditorInput
,
IUntitledTextResourceInput
,
IResourceDiffInput
,
IResourceSideBySideInput
,
IEditorInputFactoryRegistry
,
Extensions
as
EditorExtensions
,
EditorInput
,
SideBySideEditorInput
,
IEditorInputWithOptions
,
isEditorInputWithOptions
,
EditorOptions
,
TextEditorOptions
,
IEditorIdentifier
,
IEditorCloseEvent
,
ITextEditor
,
ITextDiffEditor
,
ITextSideBySideEditor
,
IRevertOptions
,
SaveReason
,
EditorsOrder
,
isTextEditor
,
ICompositeCodeEditor
,
IWorkbenchEditorConfiguration
,
toResource
}
from
'
vs/workbench/common/editor
'
;
import
{
ResourceEditorInput
}
from
'
vs/workbench/common/editor/resourceEditorInput
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
ResourceMap
}
from
'
vs/base/common/map
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录