Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
6c5037f4
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,发现更多精彩内容 >>
提交
6c5037f4
编写于
7月 17, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handle notebook text model creation in notebook service
上级
399ae189
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
30 deletion
+14
-30
src/vs/workbench/api/browser/mainThreadNotebook.ts
src/vs/workbench/api/browser/mainThreadNotebook.ts
+6
-27
src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts
...workbench/contrib/notebook/browser/notebookServiceImpl.ts
+6
-2
src/vs/workbench/contrib/notebook/common/notebookService.ts
src/vs/workbench/contrib/notebook/common/notebookService.ts
+2
-1
未找到文件。
src/vs/workbench/api/browser/mainThreadNotebook.ts
浏览文件 @
6c5037f4
...
...
@@ -18,7 +18,6 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import
{
IAccessibilityService
}
from
'
vs/platform/accessibility/common/accessibility
'
;
import
{
IRelativePattern
}
from
'
vs/base/common/glob
'
;
import
{
ExtensionIdentifier
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IUndoRedoService
}
from
'
vs/platform/undoRedo/common/undoRedo
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
...
...
@@ -168,7 +167,6 @@ class DocumentAndEditorState {
@
extHostNamedCustomer
(
MainContext
.
MainThreadNotebook
)
export
class
MainThreadNotebooks
extends
Disposable
implements
MainThreadNotebookShape
{
static
mainthreadNotebookDocumentHandle
:
number
=
0
;
private
readonly
_notebookProviders
=
new
Map
<
string
,
IMainNotebookController
>
();
private
readonly
_notebookKernels
=
new
Map
<
string
,
MainThreadNotebookKernel
>
();
private
readonly
_notebookKernelProviders
=
new
Map
<
number
,
{
extension
:
NotebookExtensionDescription
,
emitter
:
Emitter
<
void
>
,
provider
:
IDisposable
}
>
();
...
...
@@ -183,8 +181,7 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
@
INotebookService
private
_notebookService
:
INotebookService
,
@
IConfigurationService
private
readonly
configurationService
:
IConfigurationService
,
@
IEditorService
private
readonly
editorService
:
IEditorService
,
@
IAccessibilityService
private
readonly
accessibilityService
:
IAccessibilityService
,
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
@
IAccessibilityService
private
readonly
accessibilityService
:
IAccessibilityService
)
{
super
();
...
...
@@ -202,23 +199,6 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
return
false
;
}
createNotebookTextModelAndBindListeners
(
uri
:
URI
,
viewType
:
string
,
supportBackup
:
boolean
)
{
const
disposableStore
=
new
DisposableStore
();
const
textModel
=
this
.
_instantiationService
.
createInstance
(
NotebookTextModel
,
MainThreadNotebooks
.
mainthreadNotebookDocumentHandle
++
,
viewType
,
supportBackup
,
uri
);
disposableStore
.
add
(
textModel
.
onDidModelChangeProxy
(
e
=>
{
this
.
_proxy
.
$acceptModelChanged
(
textModel
.
uri
,
e
);
this
.
_proxy
.
$acceptEditorPropertiesChanged
(
uri
,
{
selections
:
{
selections
:
textModel
.
selections
},
metadata
:
null
});
}));
disposableStore
.
add
(
textModel
.
onDidSelectionChange
(
e
=>
{
const
selectionsChange
=
e
?
{
selections
:
e
}
:
null
;
this
.
_proxy
.
$acceptEditorPropertiesChanged
(
uri
,
{
selections
:
selectionsChange
,
metadata
:
null
});
}));
this
.
_editorEventListenersMapping
.
set
(
textModel
.
uri
.
toString
(),
disposableStore
);
return
textModel
;
}
async
removeNotebookTextModel
(
uri
:
URI
):
Promise
<
void
>
{
// TODO@rebornix, remove cell should use emitDelta as well to ensure document/editor events are sent together
await
this
.
_proxy
.
$acceptDocumentAndEditorsDelta
({
removedDocuments
:
[
uri
]
});
...
...
@@ -441,6 +421,7 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
async
$registerNotebookProvider
(
_extension
:
NotebookExtensionDescription
,
_viewType
:
string
,
_supportBackup
:
boolean
,
_kernel
:
INotebookKernelInfoDto
|
undefined
):
Promise
<
void
>
{
const
controller
:
IMainNotebookController
=
{
kernel
:
_kernel
,
supportBackup
:
_supportBackup
,
reloadNotebook
:
async
(
mainthreadTextModel
:
NotebookTextModel
)
=>
{
const
data
=
await
this
.
_proxy
.
$resolveNotebookData
(
_viewType
,
mainthreadTextModel
.
uri
);
if
(
!
data
)
{
...
...
@@ -463,10 +444,9 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
});
});
},
createNotebook
:
async
(
viewType
:
string
,
uri
:
URI
,
editorId
?:
string
,
backupId
?:
string
)
=>
{
const
textModel
=
this
.
createNotebookTextModelAndBindListeners
(
uri
,
viewType
,
_supportBackup
);
createNotebook
:
async
(
textModel
:
NotebookTextModel
,
backupId
?:
string
)
=>
{
// open notebook document
const
data
=
await
this
.
_proxy
.
$resolveNotebookData
(
viewType
,
uri
,
backupId
);
const
data
=
await
this
.
_proxy
.
$resolveNotebookData
(
textModel
.
viewType
,
textModel
.
uri
,
backupId
);
if
(
!
data
)
{
return
;
}
...
...
@@ -481,9 +461,8 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
textModel
.
insertTemplateCell
(
mainCell
);
}
this
.
_proxy
.
$acceptEditorPropertiesChanged
(
uri
,
{
selections
:
null
,
metadata
:
textModel
.
metadata
});
return
textModel
;
this
.
_proxy
.
$acceptEditorPropertiesChanged
(
textModel
.
uri
,
{
selections
:
null
,
metadata
:
textModel
.
metadata
});
return
;
},
resolveNotebookEditor
:
async
(
viewType
:
string
,
uri
:
URI
,
editorId
:
string
)
=>
{
await
this
.
_proxy
.
$resolveNotebookEditor
(
viewType
,
uri
,
editorId
);
...
...
src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts
浏览文件 @
6c5037f4
...
...
@@ -29,6 +29,7 @@ import { StorageScope, IStorageService } from 'vs/platform/storage/common/storag
import
{
IExtensionPointUser
}
from
'
vs/workbench/services/extensions/common/extensionsRegistry
'
;
import
{
generateUuid
}
from
'
vs/base/common/uuid
'
;
import
{
flatten
}
from
'
vs/base/common/arrays
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
function
MODEL_ID
(
resource
:
URI
):
string
{
return
resource
.
toString
();
...
...
@@ -166,6 +167,7 @@ class ModelData implements IDisposable {
}
export
class
NotebookService
extends
Disposable
implements
INotebookService
,
ICustomEditorViewTypesHandler
{
declare
readonly
_serviceBrand
:
undefined
;
static
mainthreadNotebookDocumentHandle
:
number
=
0
;
private
readonly
_notebookProviders
=
new
Map
<
string
,
{
controller
:
IMainNotebookController
,
extensionData
:
NotebookExtensionDescription
}
>
();
private
readonly
_notebookRenderers
=
new
Map
<
string
,
INotebookRendererInfo
>
();
private
readonly
_notebookKernels
=
new
Map
<
string
,
INotebookKernelInfo
>
();
...
...
@@ -205,7 +207,8 @@ export class NotebookService extends Disposable implements INotebookService, ICu
@
IEditorService
private
readonly
_editorService
:
IEditorService
,
@
IConfigurationService
private
readonly
_configurationService
:
IConfigurationService
,
@
IAccessibilityService
private
readonly
_accessibilityService
:
IAccessibilityService
,
@
IStorageService
private
readonly
_storageService
:
IStorageService
@
IStorageService
private
readonly
_storageService
:
IStorageService
,
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
)
{
super
();
...
...
@@ -411,7 +414,8 @@ export class NotebookService extends Disposable implements INotebookService, ICu
return
notebookModel
;
}
else
{
notebookModel
=
await
provider
.
controller
.
createNotebook
(
viewType
,
uri
,
editorId
,
backupId
);
notebookModel
=
this
.
_instantiationService
.
createInstance
(
NotebookTextModel
,
NotebookService
.
mainthreadNotebookDocumentHandle
++
,
viewType
,
provider
.
controller
.
supportBackup
,
uri
);
await
provider
.
controller
.
createNotebook
(
notebookModel
,
backupId
);
if
(
!
notebookModel
)
{
return
undefined
;
...
...
src/vs/workbench/contrib/notebook/common/notebookService.ts
浏览文件 @
6c5037f4
...
...
@@ -22,7 +22,8 @@ export const INotebookService = createDecorator<INotebookService>('notebookServi
export
interface
IMainNotebookController
{
kernel
:
INotebookKernelInfoDto
|
undefined
;
createNotebook
(
viewType
:
string
,
uri
:
URI
,
editorId
?:
string
,
backupId
?:
string
):
Promise
<
NotebookTextModel
|
undefined
>
;
supportBackup
:
boolean
;
createNotebook
(
textModel
:
NotebookTextModel
,
editorId
?:
string
,
backupId
?:
string
):
Promise
<
void
>
;
reloadNotebook
(
mainthreadTextModel
:
NotebookTextModel
):
Promise
<
void
>
;
resolveNotebookEditor
(
viewType
:
string
,
uri
:
URI
,
editorId
:
string
):
Promise
<
void
>
;
executeNotebookByAttachedKernel
(
viewType
:
string
,
uri
:
URI
,
token
:
CancellationToken
):
Promise
<
void
>
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录