Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4bced156
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,发现更多精彩内容 >>
提交
4bced156
编写于
2月 18, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
notebook cell update with renderer updates.
上级
796c2baa
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
96 addition
and
21 deletion
+96
-21
src/vs/workbench/api/browser/mainThreadNotebook.ts
src/vs/workbench/api/browser/mainThreadNotebook.ts
+8
-6
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+2
-2
src/vs/workbench/api/common/extHostNotebook.ts
src/vs/workbench/api/common/extHostNotebook.ts
+86
-13
未找到文件。
src/vs/workbench/api/browser/mainThreadNotebook.ts
浏览文件 @
4bced156
...
...
@@ -278,14 +278,14 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
return
handle
;
}
async
$spliceNotebookCells
(
viewType
:
string
,
resource
:
UriComponents
,
splices
:
NotebookCellsSplice
[]):
Promise
<
void
>
{
async
$spliceNotebookCells
(
viewType
:
string
,
resource
:
UriComponents
,
splices
:
NotebookCellsSplice
[]
,
renderers
:
number
[]
):
Promise
<
void
>
{
let
controller
=
this
.
_notebookProviders
.
get
(
viewType
);
controller
?.
spliceNotebookCells
(
resource
,
splices
);
controller
?.
spliceNotebookCells
(
resource
,
splices
,
renderers
);
}
async
$spliceNotebookCellOutputs
(
viewType
:
string
,
resource
:
UriComponents
,
cellHandle
:
number
,
splices
:
NotebookCellOutputsSplice
[]):
Promise
<
void
>
{
async
$spliceNotebookCellOutputs
(
viewType
:
string
,
resource
:
UriComponents
,
cellHandle
:
number
,
splices
:
NotebookCellOutputsSplice
[]
,
renderers
:
number
[]
):
Promise
<
void
>
{
let
controller
=
this
.
_notebookProviders
.
get
(
viewType
);
controller
?.
spliceNotebookCellOutputs
(
resource
,
cellHandle
,
splices
);
controller
?.
spliceNotebookCellOutputs
(
resource
,
cellHandle
,
splices
,
renderers
);
}
async
executeNotebook
(
viewType
:
string
,
uri
:
URI
):
Promise
<
void
>
{
...
...
@@ -320,13 +320,15 @@ export class MainThreadNotebookController implements IMainNotebookController {
return
undefined
;
}
spliceNotebookCells
(
resource
:
UriComponents
,
splices
:
NotebookCellsSplice
[]):
void
{
spliceNotebookCells
(
resource
:
UriComponents
,
splices
:
NotebookCellsSplice
[]
,
renderers
:
number
[]
):
void
{
let
mainthreadNotebook
=
this
.
_mapping
.
get
(
URI
.
from
(
resource
).
toString
());
mainthreadNotebook
?.
updateRenderers
(
renderers
);
mainthreadNotebook
?.
spliceNotebookCells
(
splices
);
}
spliceNotebookCellOutputs
(
resource
:
UriComponents
,
cellHandle
:
number
,
splices
:
NotebookCellOutputsSplice
[]):
void
{
spliceNotebookCellOutputs
(
resource
:
UriComponents
,
cellHandle
:
number
,
splices
:
NotebookCellOutputsSplice
[]
,
renderers
:
number
[]
):
void
{
let
mainthreadNotebook
=
this
.
_mapping
.
get
(
URI
.
from
(
resource
).
toString
());
mainthreadNotebook
?.
updateRenderers
(
renderers
);
mainthreadNotebook
?.
spliceNotebookCellOutputs
(
cellHandle
,
splices
);
}
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
4bced156
...
...
@@ -661,8 +661,8 @@ export interface MainThreadNotebookShape extends IDisposable {
$unregisterNotebookRenderer
(
handle
:
number
):
Promise
<
void
>
;
$createNotebookDocument
(
handle
:
number
,
viewType
:
string
,
resource
:
UriComponents
):
Promise
<
void
>
;
$updateNotebookLanguages
(
viewType
:
string
,
resource
:
UriComponents
,
languages
:
string
[]):
Promise
<
void
>
;
$spliceNotebookCells
(
viewType
:
string
,
resource
:
UriComponents
,
splices
:
NotebookCellsSplice
[]):
Promise
<
void
>
;
$spliceNotebookCellOutputs
(
viewType
:
string
,
resource
:
UriComponents
,
cellHandle
:
number
,
splices
:
NotebookCellOutputsSplice
[]):
Promise
<
void
>
;
$spliceNotebookCells
(
viewType
:
string
,
resource
:
UriComponents
,
splices
:
NotebookCellsSplice
[]
,
renderers
:
number
[]
):
Promise
<
void
>
;
$spliceNotebookCellOutputs
(
viewType
:
string
,
resource
:
UriComponents
,
cellHandle
:
number
,
splices
:
NotebookCellOutputsSplice
[]
,
renderers
:
number
[]
):
Promise
<
void
>
;
}
export
interface
MainThreadUrlsShape
extends
IDisposable
{
...
...
src/vs/workbench/api/common/extHostNotebook.ts
浏览文件 @
4bced156
...
...
@@ -5,7 +5,7 @@
import
*
as
vscode
from
'
vscode
'
;
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
{
ExtHostNotebookShape
,
IMainContext
,
MainThreadNotebookShape
,
MainContext
,
ICellDto
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
ExtHostNotebookShape
,
IMainContext
,
MainThreadNotebookShape
,
MainContext
,
ICellDto
,
NotebookCellsSplice
,
NotebookCellOutputsSplice
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
Disposable
as
VSCodeDisposable
}
from
'
./extHostTypes
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
...
...
@@ -13,7 +13,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
import
{
readonly
}
from
'
vs/base/common/errors
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
ExtHostDocumentsAndEditors
}
from
'
vs/workbench/api/common/extHostDocumentsAndEditors
'
;
import
{
INotebookDisplayOrder
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookDisplayOrder
,
IGenericOutput
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
ISplice
}
from
'
vs/base/common/sequence
'
;
interface
ExtHostOutputDisplayOrder
{
...
...
@@ -109,7 +109,7 @@ export class ExtHostCell implements vscode.NotebookCell {
}
set
outputs
(
newOutputs
:
any
[])
{
let
diffs
=
diff
<
vscode
.
CellOutput
>
(
this
.
_outputs
,
newOutputs
,
(
a
)
=>
{
let
diffs
=
diff
<
vscode
.
CellOutput
>
(
this
.
_outputs
||
[],
newOutputs
||
[]
,
(
a
)
=>
{
return
this
.
_outputMapping
.
has
(
a
);
});
...
...
@@ -177,7 +177,7 @@ export class ExtHostNotebookDocument implements vscode.NotebookDocument {
diff
.
toInsert
.
forEach
(
cell
=>
{
this
.
_cellDisposableMapping
.
set
(
cell
.
handle
,
new
DisposableStore
());
this
.
_cellDisposableMapping
.
get
(
cell
.
handle
)?.
add
(
cell
.
onDidChangeOutputs
((
outputDiffs
)
=>
{
this
.
_proxy
.
$spliceNotebookCellOutputs
(
this
.
viewType
,
this
.
uri
,
cell
.
handle
,
outputDiffs
.
map
(
diff
=>
[
diff
.
start
,
diff
.
deleteCount
,
diff
.
toInsert
])
);
this
.
eventuallyUpdateCellOutputs
(
cell
,
outputDiffs
);
}));
});
});
...
...
@@ -227,21 +227,94 @@ export class ExtHostNotebookDocument implements vscode.NotebookDocument {
get
isDirty
()
{
return
false
;
}
eventuallyUpdateCells
(
diffs
:
ISplice
<
ExtHostCell
>
[])
{
this
.
_proxy
.
$spliceNotebookCells
(
this
.
viewType
,
this
.
uri
,
diffs
.
map
(
diff
=>
[
diff
.
start
,
diff
.
deleteCount
,
diff
.
toInsert
.
map
(
cell
=>
({
let
renderers
=
new
Set
<
number
>
();
let
diffDtos
:
NotebookCellsSplice
[]
=
[];
diffDtos
=
diffs
.
map
(
diff
=>
{
let
inserts
=
diff
.
toInsert
;
let
cellDtos
=
inserts
.
map
(
cell
=>
{
let
outputs
=
cell
.
outputs
;
if
(
outputs
&&
outputs
.
length
)
{
outputs
=
outputs
.
map
(
output
=>
{
let
richestMimeType
:
string
|
undefined
=
undefined
;
if
(
this
.
renderingHandler
.
outputDisplayOrder
?.
userOrder
||
this
.
_parsedDisplayOrder
.
length
>
0
)
{
richestMimeType
=
this
.
findRichestMimeType
(
output
);
}
let
transformedOutput
:
vscode
.
CellOutput
|
undefined
=
undefined
;
if
(
richestMimeType
)
{
let
handler
=
this
.
renderingHandler
.
findBestMatchedRenderer
(
richestMimeType
);
if
(
handler
)
{
renderers
.
add
(
handler
.
handle
);
transformedOutput
=
handler
?.
render
(
this
,
cell
,
output
);
output
=
transformedOutput
;
output
.
pickedMimeType
=
richestMimeType
;
}
}
return
output
;
});
}
return
{
handle
:
cell
.
handle
,
source
:
cell
.
source
,
language
:
cell
.
language
,
cell_type
:
cell
.
cell_type
,
outputs
:
cell
.
outputs
}))]
)
outputs
:
outputs
,
isDirty
:
false
};
});
return
[
diff
.
start
,
diff
.
deleteCount
,
cellDtos
];
});
this
.
_proxy
.
$spliceNotebookCells
(
this
.
viewType
,
this
.
uri
,
diffDtos
,
Array
.
from
(
renderers
)
);
}
eventuallyUpdateCellOutputs
(
cell
:
ExtHostCell
,
diffs
:
ISplice
<
vscode
.
CellOutput
>
[])
{
let
renderers
=
new
Set
<
number
>
();
let
outputDtos
:
NotebookCellOutputsSplice
[]
=
diffs
.
map
(
diff
=>
{
let
outputs
=
diff
.
toInsert
;
outputs
=
outputs
.
map
(
output
=>
{
let
richestMimeType
:
string
|
undefined
=
undefined
;
if
(
this
.
renderingHandler
.
outputDisplayOrder
?.
userOrder
||
this
.
_parsedDisplayOrder
.
length
>
0
)
{
richestMimeType
=
this
.
findRichestMimeType
(
output
);
}
let
transformedOutput
:
vscode
.
CellOutput
|
undefined
=
undefined
;
if
(
richestMimeType
)
{
let
handler
=
this
.
renderingHandler
.
findBestMatchedRenderer
(
richestMimeType
);
if
(
handler
)
{
renderers
.
add
(
handler
.
handle
);
transformedOutput
=
handler
?.
render
(
this
,
cell
,
output
);
output
=
transformedOutput
;
(
<
IGenericOutput
>
output
).
pickedMimeType
=
richestMimeType
;
}
}
return
output
;
});
return
[
diff
.
start
,
diff
.
deleteCount
,
outputs
];
});
this
.
_proxy
.
$spliceNotebookCellOutputs
(
this
.
viewType
,
this
.
uri
,
cell
.
handle
,
outputDtos
,
Array
.
from
(
renderers
));
}
insertCell
(
index
:
number
,
cell
:
ExtHostCell
)
{
this
.
cells
.
splice
(
index
,
0
,
cell
);
...
...
@@ -252,7 +325,7 @@ export class ExtHostNotebookDocument implements vscode.NotebookDocument {
let
store
=
this
.
_cellDisposableMapping
.
get
(
cell
.
handle
)
!
;
store
.
add
(
cell
.
onDidChangeOutputs
((
diffs
)
=>
{
this
.
_proxy
.
$spliceNotebookCellOutputs
(
this
.
viewType
,
this
.
uri
,
cell
.
handle
,
diffs
.
map
(
diff
=>
[
diff
.
start
,
diff
.
deleteCount
,
diff
.
toInsert
])
);
this
.
eventuallyUpdateCellOutputs
(
cell
,
diffs
);
}));
this
.
eventuallyUpdateCells
([{
start
:
index
,
deleteCount
:
0
,
toInsert
:
[
cell
]
}]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录