Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
5024a705
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,发现更多精彩内容 >>
提交
5024a705
编写于
2月 05, 2021
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
convert output exthost/main. not optimized.
上级
0a972947
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
113 addition
and
128 deletion
+113
-128
scripts/test-integration.bat
scripts/test-integration.bat
+12
-12
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+3
-3
src/vs/workbench/api/common/extHostNotebookDocument.ts
src/vs/workbench/api/common/extHostNotebookDocument.ts
+8
-12
src/vs/workbench/api/common/extHostTypeConverters.ts
src/vs/workbench/api/common/extHostTypeConverters.ts
+3
-4
src/vs/workbench/api/common/extHostTypes.ts
src/vs/workbench/api/common/extHostTypes.ts
+31
-1
src/vs/workbench/contrib/notebook/browser/diff/diffComponents.ts
...workbench/contrib/notebook/browser/diff/diffComponents.ts
+2
-2
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
+2
-2
src/vs/workbench/contrib/notebook/browser/notebookRegistry.ts
...vs/workbench/contrib/notebook/browser/notebookRegistry.ts
+2
-4
src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts
...workbench/contrib/notebook/browser/notebookServiceImpl.ts
+12
-24
src/vs/workbench/contrib/notebook/browser/view/output/outputRenderer.ts
...ch/contrib/notebook/browser/view/output/outputRenderer.ts
+5
-7
src/vs/workbench/contrib/notebook/browser/view/output/transforms/richTransform.ts
.../notebook/browser/view/output/transforms/richTransform.ts
+1
-2
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
...ntrib/notebook/browser/view/renderers/backLayerWebView.ts
+2
-3
src/vs/workbench/contrib/notebook/browser/viewModel/cellEdit.ts
.../workbench/contrib/notebook/browser/viewModel/cellEdit.ts
+2
-2
src/vs/workbench/contrib/notebook/browser/viewModel/cellOutputViewModel.ts
...contrib/notebook/browser/viewModel/cellOutputViewModel.ts
+3
-3
src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts
...h/contrib/notebook/browser/viewModel/notebookViewModel.ts
+2
-2
src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts
...ch/contrib/notebook/common/model/notebookCellTextModel.ts
+4
-4
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
...kbench/contrib/notebook/common/model/notebookTextModel.ts
+4
-11
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
+7
-14
src/vs/workbench/contrib/notebook/common/notebookService.ts
src/vs/workbench/contrib/notebook/common/notebookService.ts
+2
-2
src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.ts
.../contrib/notebook/common/services/notebookSimpleWorker.ts
+2
-2
src/vs/workbench/contrib/notebook/test/notebookTextModel.test.ts
...workbench/contrib/notebook/test/notebookTextModel.test.ts
+1
-9
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
+3
-3
未找到文件。
scripts/test-integration.bat
浏览文件 @
5024a705
...
...
@@ -45,23 +45,23 @@ if "%INTEGRATION_TEST_ELECTRON_PATH%"=="" (
:: Tests in the extension host
call
"
%INTEGRATION_TEST_ELECTRON_PATH%
"
%~dp0
\..\extensions\vscode
-api-tests
\testWorkspace
--enable-proposed-api
=
vscode
.vscode
-api-tests --extensionDevelopmentPath
=
%~dp0
\..\extensions\vscode
-api-tests --extensionTestsPath
=
%~dp0
\..\extensions\vscode
-api-tests
\out\singlefolder
-tests --disable-telemetry --crash-reporter-directory
=
%VSCODECRASHDIR%
--no-cached-data --disable-updates --disable-extensions --user-data-dir
=
%VSCODEUSERDATADIR%
if
%errorlevel%
neq
0
exit
/b
%errorlevel%
@REM
call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\vscode-api-tests\testWorkspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=%~dp0\..\extensions\vscode-api-tests --extensionTestsPath=%~dp0\..\extensions\vscode-api-tests\out\singlefolder-tests --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
@REM
if %errorlevel% neq 0 exit /b %errorlevel%
call
"
%INTEGRATION_TEST_ELECTRON_PATH%
"
%~dp0
\..\extensions\vscode
-api-tests
\testworkspace.code
-workspace --enable-proposed-api
=
vscode
.vscode
-api-tests --extensionDevelopmentPath
=
%~dp0
\..\extensions\vscode
-api-tests --extensionTestsPath
=
%~dp0
\..\extensions\vscode
-api-tests
\out\workspace
-tests --disable-telemetry --crash-reporter-directory
=
%VSCODECRASHDIR%
--no-cached-data --disable-updates --disable-extensions --user-data-dir
=
%VSCODEUSERDATADIR%
if
%errorlevel%
neq
0
exit
/b
%errorlevel%
@REM
call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\vscode-api-tests\testworkspace.code-workspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=%~dp0\..\extensions\vscode-api-tests --extensionTestsPath=%~dp0\..\extensions\vscode-api-tests\out\workspace-tests --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
@REM
if %errorlevel% neq 0 exit /b %errorlevel%
call
"
%INTEGRATION_TEST_ELECTRON_PATH%
"
%~dp0
\..\extensions\vscode
-colorize-tests
\test
--extensionDevelopmentPath
=
%~dp0
\..\extensions\vscode
-colorize-tests --extensionTestsPath
=
%~dp0
\..\extensions\vscode
-colorize-tests
\out
--disable-telemetry --crash-reporter-directory
=
%VSCODECRASHDIR%
--no-cached-data --disable-updates --disable-extensions --user-data-dir
=
%VSCODEUSERDATADIR%
if
%errorlevel%
neq
0
exit
/b
%errorlevel%
@REM
call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\vscode-colorize-tests\test --extensionDevelopmentPath=%~dp0\..\extensions\vscode-colorize-tests --extensionTestsPath=%~dp0\..\extensions\vscode-colorize-tests\out --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
@REM
if %errorlevel% neq 0 exit /b %errorlevel%
call
"
%INTEGRATION_TEST_ELECTRON_PATH%
"
%~dp0
\..\extensions\typescript
-language-features
\test
-workspace --extensionDevelopmentPath
=
%~dp0
\..\extensions\typescript
-language-features --extensionTestsPath
=
%~dp0
\..\extensions\typescript
-language-features
\out\test\unit
--disable-telemetry --crash-reporter-directory
=
%VSCODECRASHDIR%
--no-cached-data --disable-updates --disable-extensions --user-data-dir
=
%VSCODEUSERDATADIR%
if
%errorlevel%
neq
0
exit
/b
%errorlevel%
@REM
call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\typescript-language-features\test-workspace --extensionDevelopmentPath=%~dp0\..\extensions\typescript-language-features --extensionTestsPath=%~dp0\..\extensions\typescript-language-features\out\test\unit --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
@REM
if %errorlevel% neq 0 exit /b %errorlevel%
call
"
%INTEGRATION_TEST_ELECTRON_PATH%
"
%~dp0
\..\extensions\markdown
-language-features
\test
-workspace --extensionDevelopmentPath
=
%~dp0
\..\extensions\markdown
-language-features --extensionTestsPath
=
%~dp0
\..\extensions\markdown
-language-features
\out\test
--disable-telemetry --crash-reporter-directory
=
%VSCODECRASHDIR%
--no-cached-data --disable-updates --disable-extensions --user-data-dir
=
%VSCODEUSERDATADIR%
if
%errorlevel%
neq
0
exit
/b
%errorlevel%
@REM
call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\markdown-language-features\test-workspace --extensionDevelopmentPath=%~dp0\..\extensions\markdown-language-features --extensionTestsPath=%~dp0\..\extensions\markdown-language-features\out\test --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
@REM
if %errorlevel% neq 0 exit /b %errorlevel%
call
"
%INTEGRATION_TEST_ELECTRON_PATH%
"
$
%~dp0
\..\extensions\emmet\out\test\test
-fixtures --extensionDevelopmentPath
=
%~dp0
\..\extensions\emmet
--extensionTestsPath
=
%~dp0
\..\extensions\emmet\out\test
--disable-telemetry --crash-reporter-directory
=
%VSCODECRASHDIR%
--no-cached-data --disable-updates --disable-extensions --user-data-dir
=
%VSCODEUSERDATADIR%
.
if
%errorlevel%
neq
0
exit
/b
%errorlevel%
@REM
call "%INTEGRATION_TEST_ELECTRON_PATH%" $%~dp0\..\extensions\emmet\out\test\test-fixtures --extensionDevelopmentPath=%~dp0\..\extensions\emmet --extensionTestsPath=%~dp0\..\extensions\emmet\out\test --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR% .
@REM
if %errorlevel% neq 0 exit /b %errorlevel%
call
"
%INTEGRATION_TEST_ELECTRON_PATH%
"
%~dp0
\..\extensions\vscode
-notebook-tests
\test
--enable-proposed-api
=
vscode
.vscode
-notebook-tests --extensionDevelopmentPath
=
%~dp0
\..\extensions\vscode
-notebook-tests --extensionTestsPath
=
%~dp0
\..\extensions\vscode
-notebook-tests
\out
--disable-telemetry --crash-reporter-directory
=
%VSCODECRASHDIR%
--no-cached-data --disable-updates --disable-extensions --user-data-dir
=
%VSCODEUSERDATADIR%
if
%errorlevel%
neq
0
exit
/b
%errorlevel%
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
5024a705
...
...
@@ -51,7 +51,7 @@ import { TunnelDto } from 'vs/workbench/api/common/extHostTunnelService';
import
{
TunnelCreationOptions
,
TunnelProviderFeatures
,
TunnelOptions
}
from
'
vs/platform/remote/common/tunnel
'
;
import
{
Timeline
,
TimelineChangeEvent
,
TimelineOptions
,
TimelineProviderDescriptor
,
InternalTimelineOptions
}
from
'
vs/workbench/contrib/timeline/common/timeline
'
;
import
{
revive
}
from
'
vs/base/common/marshalling
'
;
import
{
I
DisplayOutputDto
,
INotebookDisplayOrder
,
NotebookCellMetadata
,
NotebookDocumentMetadata
,
ICellEditOperation
,
NotebookCellsChangedEventDto
,
NotebookDataDto
,
IMainCellDto
,
INotebookDocumentFilter
,
INotebookKernelInfoDto2
,
TransientMetadata
,
INotebookCellStatusBarEntry
,
ICellRange
,
INotebookDecorationRenderOptions
,
INotebookExclusiveDocumentFilter
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
I
NotebookDisplayOrder
,
NotebookCellMetadata
,
NotebookDocumentMetadata
,
ICellEditOperation
,
NotebookCellsChangedEventDto
,
NotebookDataDto
,
IMainCellDto
,
INotebookDocumentFilter
,
INotebookKernelInfoDto2
,
TransientMetadata
,
INotebookCellStatusBarEntry
,
ICellRange
,
INotebookDecorationRenderOptions
,
INotebookExclusiveDocumentFilter
,
IOutputDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CallHierarchyItem
}
from
'
vs/workbench/contrib/callHierarchy/common/callHierarchy
'
;
import
{
Dto
}
from
'
vs/base/common/types
'
;
import
{
ISerializableEnvironmentVariableCollection
}
from
'
vs/workbench/contrib/terminal/common/environmentVariable
'
;
...
...
@@ -744,7 +744,7 @@ export interface ICellDto {
source
:
string
[];
language
:
string
;
cellKind
:
CellKind
;
outputs
:
I
Display
OutputDto
[];
outputs
:
IOutputDto
[];
metadata
?:
NotebookCellMetadata
;
}
...
...
@@ -757,7 +757,7 @@ export type NotebookCellsSplice = [
export
type
NotebookCellOutputsSplice
=
[
number
/* start */
,
number
/* delete count */
,
I
Display
OutputDto
[]
IOutputDto
[]
];
export
enum
NotebookEditorRevealType
{
...
...
src/vs/workbench/api/common/extHostNotebookDocument.ts
浏览文件 @
5024a705
...
...
@@ -13,7 +13,7 @@ import { URI } from 'vs/base/common/uri';
import
{
CellKind
,
INotebookDocumentPropertiesChangeData
,
IWorkspaceCellEditDto
,
MainThreadBulkEditsShape
,
MainThreadNotebookShape
,
WorkspaceEditType
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
ExtHostDocumentsAndEditors
,
IExtHostModelAddedData
}
from
'
vs/workbench/api/common/extHostDocumentsAndEditors
'
;
import
{
NotebookCellOutput
}
from
'
vs/workbench/api/common/extHostTypes
'
;
import
{
CellEditType
,
IMainCellDto
,
I
Display
OutputDto
,
NotebookCellMetadata
,
NotebookCellsChangedEventDto
,
NotebookCellsChangeType
,
NotebookCellsSplice2
,
notebookDocumentMetadataDefaults
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellEditType
,
IMainCellDto
,
IOutputDto
,
NotebookCellMetadata
,
NotebookCellsChangedEventDto
,
NotebookCellsChangeType
,
NotebookCellsSplice2
,
notebookDocumentMetadataDefaults
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
*
as
vscode
from
'
vscode
'
;
...
...
@@ -69,10 +69,10 @@ export class ExtHostCell extends Disposable {
private
_onDidDispose
=
new
Emitter
<
void
>
();
readonly
onDidDispose
:
Event
<
void
>
=
this
.
_onDidDispose
.
event
;
private
_onDidChangeOutputs
=
new
Emitter
<
ISplice
<
I
Display
OutputDto
>
[]
>
();
readonly
onDidChangeOutputs
:
Event
<
ISplice
<
I
Display
OutputDto
>
[]
>
=
this
.
_onDidChangeOutputs
.
event
;
private
_onDidChangeOutputs
=
new
Emitter
<
ISplice
<
IOutputDto
>
[]
>
();
readonly
onDidChangeOutputs
:
Event
<
ISplice
<
IOutputDto
>
[]
>
=
this
.
_onDidChangeOutputs
.
event
;
private
_outputs
:
I
Display
OutputDto
[];
private
_outputs
:
IOutputDto
[];
private
_metadata
:
vscode
.
NotebookCellMetadata
;
...
...
@@ -114,14 +114,10 @@ export class ExtHostCell extends Disposable {
document
:
data
.
document
,
get
language
()
{
return
data
!
.
document
.
languageId
;
},
get
outputs
()
{
return
that
.
_outputs
.
map
(
ouptput
=>
{
const
copy
:
vscode
.
CellOutput
&
{
outputId
?:
string
}
=
{
...
ouptput
};
delete
copy
.
outputId
;
return
copy
;
});
return
that
.
_outputs
.
map
(
output
=>
NotebookCellOutput
.
_toOld
(
output
));
},
set
outputs
(
_value
)
{
throw
new
Error
(
'
Use WorkspaceEdit to update cell outputs.
'
);
},
get
outputs2
()
{
return
that
.
_outputs
.
map
(
output
=>
NotebookCellOutput
.
_from
Old
(
output
,
output
.
outputId
));
},
get
outputs2
()
{
return
that
.
_outputs
.
map
(
output
=>
NotebookCellOutput
.
_from
Dto
(
output
,
output
.
outputId
));
},
set
outputs2
(
_value
)
{
throw
new
Error
(
'
Use WorkspaceEdit to update cell outputs.
'
);
},
get
metadata
()
{
return
that
.
_metadata
;
},
set
metadata
(
_value
)
{
throw
new
Error
(
'
Use WorkspaceEdit to update cell metadata.
'
);
},
...
...
@@ -135,7 +131,7 @@ export class ExtHostCell extends Disposable {
this
.
_onDidDispose
.
fire
();
}
setOutputs
(
newOutputs
:
I
Display
OutputDto
[]):
void
{
setOutputs
(
newOutputs
:
IOutputDto
[]):
void
{
this
.
_outputs
=
newOutputs
;
}
...
...
@@ -390,7 +386,7 @@ export class ExtHostNotebookDocument extends Disposable {
});
}
private
_setCellOutputs
(
index
:
number
,
outputs
:
I
Display
OutputDto
[]):
void
{
private
_setCellOutputs
(
index
:
number
,
outputs
:
IOutputDto
[]):
void
{
const
cell
=
this
.
_cells
[
index
];
cell
.
setOutputs
(
outputs
);
this
.
_emitter
.
emitCellOutputsChange
({
document
:
this
.
notebookDocument
,
cells
:
[
cell
.
cell
]
});
...
...
src/vs/workbench/api/common/extHostTypeConverters.ts
浏览文件 @
5024a705
...
...
@@ -31,7 +31,7 @@ import { coalesce, isNonEmptyArray } from 'vs/base/common/arrays';
import
{
RenderLineNumbersType
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
CommandsConverter
}
from
'
vs/workbench/api/common/extHostCommands
'
;
import
{
ExtHostNotebookController
}
from
'
vs/workbench/api/common/extHostNotebook
'
;
import
{
CellEditType
,
CellOutputKind
,
ICellDto2
,
INotebookDecorationRenderOptions
,
IDisplay
OutputDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellEditType
,
ICellDto2
,
INotebookDecorationRenderOptions
,
I
OutputDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
ITestItem
,
ITestState
}
from
'
vs/workbench/contrib/testing/common/testCollection
'
;
export
interface
PositionLike
{
...
...
@@ -1322,7 +1322,7 @@ export namespace LanguageSelector {
export
namespace
NotebookCellData
{
export
function
from
(
data
:
vscode
.
NotebookCellData
):
ICellDto2
{
let
outputs
:
I
Display
OutputDto
[];
let
outputs
:
IOutputDto
[];
const
[
first
]
=
data
.
outputs
;
if
(
!
first
)
{
outputs
=
[];
...
...
@@ -1342,7 +1342,7 @@ export namespace NotebookCellData {
}
export
namespace
NotebookCellOutput
{
export
function
from
(
output
:
types
.
NotebookCellOutput
):
I
Display
OutputDto
{
export
function
from
(
output
:
types
.
NotebookCellOutput
):
IOutputDto
{
const
data
=
Object
.
create
(
null
);
const
custom
=
Object
.
create
(
null
);
...
...
@@ -1354,7 +1354,6 @@ export namespace NotebookCellOutput {
return
{
outputId
:
output
.
id
,
outputKind
:
CellOutputKind
.
Rich
,
data
,
metadata
:
isEmptyObject
(
custom
)
?
undefined
:
{
custom
}
};
...
...
src/vs/workbench/api/common/extHostTypes.ts
浏览文件 @
5024a705
...
...
@@ -13,7 +13,7 @@ import { URI } from 'vs/base/common/uri';
import
{
generateUuid
}
from
'
vs/base/common/uuid
'
;
import
{
FileSystemProviderErrorCode
,
markAsFileSystemProviderError
}
from
'
vs/platform/files/common/files
'
;
import
{
RemoteAuthorityResolverErrorCode
}
from
'
vs/platform/remote/common/remoteAuthorityResolver
'
;
import
{
CellEditType
,
ICellEditOperation
,
notebookDocumentMetadataDefaults
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellEditType
,
ICellEditOperation
,
IOutputDto
,
notebookDocumentMetadataDefaults
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
type
*
as
vscode
from
'
vscode
'
;
function
es5ClassCompat
(
target
:
Function
):
any
{
...
...
@@ -2843,6 +2843,36 @@ export class NotebookCellOutputItem {
export
class
NotebookCellOutput
{
static
_toOld
(
output
:
IOutputDto
):
vscode
.
CellOutput
{
if
(
output
.
data
[
'
application/x.notebook.stream
'
])
{
return
{
outputKind
:
CellOutputKind
.
Text
,
text
:
output
.
data
[
'
application/x.notebook.stream
'
]
as
string
};
}
else
if
(
output
.
data
[
'
application/x.notebook.error-traceback
'
])
{
return
{
outputKind
:
CellOutputKind
.
Error
,
ename
:
(
output
.
data
[
'
application/x.notebook.error-traceback
'
]
as
any
)[
'
ename
'
],
evalue
:
(
output
.
data
[
'
application/x.notebook.error-traceback
'
]
as
any
)[
'
evalue
'
],
traceback
:
(
output
.
data
[
'
application/x.notebook.error-traceback
'
]
as
any
)[
'
traceback
'
],
};
}
else
{
return
{
outputKind
:
CellOutputKind
.
Rich
,
data
:
output
.
data
,
metadata
:
output
.
metadata
};
}
}
static
_fromDto
(
output
:
IOutputDto
,
id
?:
string
)
{
const
items
:
NotebookCellOutputItem
[]
=
[];
for
(
const
key
in
output
.
data
)
{
items
.
push
(
new
NotebookCellOutputItem
(
key
,
output
.
data
[
key
],
output
.
metadata
?.
custom
?
output
.
metadata
?.
custom
[
key
]
:
undefined
));
}
return
new
NotebookCellOutput
(
items
,
id
);
}
static
_fromOld
(
output
:
vscode
.
CellOutput
,
id
?:
string
):
NotebookCellOutput
{
switch
(
output
.
outputKind
)
{
case
CellOutputKind
.
Error
:
...
...
src/vs/workbench/contrib/notebook/browser/diff/diffComponents.ts
浏览文件 @
5024a705
...
...
@@ -14,7 +14,7 @@ import { CodeEditorWidget, ICodeEditorWidgetOptions } from 'vs/editor/browser/wi
import
{
DiffEditorWidget
}
from
'
vs/editor/browser/widget/diffEditorWidget
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
CellEditType
,
CellUri
,
I
Display
OutputDto
,
NotebookCellMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellEditType
,
CellUri
,
IOutputDto
,
NotebookCellMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
ToolBar
}
from
'
vs/base/browser/ui/toolbar/toolbar
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IMenu
,
IMenuService
,
MenuId
,
MenuItemAction
}
from
'
vs/platform/actions/common/actions
'
;
...
...
@@ -564,7 +564,7 @@ abstract class AbstractElementRenderer extends Disposable {
}
}
private
_getFormatedOutputJSON
(
outputs
:
I
Display
OutputDto
[])
{
private
_getFormatedOutputJSON
(
outputs
:
IOutputDto
[])
{
return
JSON
.
stringify
(
outputs
,
undefined
,
'
\t
'
);
}
...
...
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
浏览文件 @
5024a705
...
...
@@ -22,7 +22,7 @@ import { OutputRenderer } from 'vs/workbench/contrib/notebook/browser/view/outpu
import
{
RunStateRenderer
,
TimerRenderer
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer
'
;
import
{
CellViewModel
,
IModelDecorationsChangeAccessor
,
NotebookViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
CellKind
,
NotebookCellMetadata
,
NotebookDocumentMetadata
,
IEditor
,
INotebookKernelInfo2
,
ICellRange
,
IOrderedMimeType
,
I
Display
OutputDto
,
INotebookRendererInfo
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
NotebookCellMetadata
,
NotebookDocumentMetadata
,
IEditor
,
INotebookKernelInfo2
,
ICellRange
,
IOrderedMimeType
,
IOutputDto
,
INotebookRendererInfo
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
Webview
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
NotebookTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookTextModel
'
;
import
{
IMenu
}
from
'
vs/platform/actions/common/actions
'
;
...
...
@@ -110,7 +110,7 @@ export interface ICellOutputViewModel {
/**
* When rendering an output, `model` should always be used as we convert legacy `text/error` output to `display_data` output under the hood.
*/
model
:
I
Display
OutputDto
;
model
:
IOutputDto
;
resolveMimeTypes
(
textModel
:
NotebookTextModel
):
[
readonly
IOrderedMimeType
[],
number
];
pickedMimeType
:
number
;
supportAppend
():
boolean
;
...
...
src/vs/workbench/contrib/notebook/browser/notebookRegistry.ts
浏览文件 @
5024a705
...
...
@@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
CellOutputKind
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
BrandedService
,
IConstructorSignature1
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ICommonNotebookEditor
,
IOutputTransformContribution
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
...
...
@@ -11,7 +10,6 @@ export type IOutputTransformCtor = IConstructorSignature1<ICommonNotebookEditor,
export
interface
IOutputTransformDescription
{
id
:
string
;
kind
:
CellOutputKind
;
ctor
:
IOutputTransformCtor
;
}
...
...
@@ -20,8 +18,8 @@ export const NotebookRegistry = new class NotebookRegistryImpl {
readonly
outputTransforms
:
IOutputTransformDescription
[]
=
[];
registerOutputTransform
<
Services
extends
BrandedService
[]
>
(
id
:
string
,
kind
:
CellOutputKind
,
ctor
:
{
new
(
editor
:
ICommonNotebookEditor
,
...
services
:
Services
):
IOutputTransformContribution
}):
void
{
this
.
outputTransforms
.
push
({
id
:
id
,
kind
:
kind
,
ctor
:
ctor
as
IOutputTransformCtor
});
registerOutputTransform
<
Services
extends
BrandedService
[]
>
(
id
:
string
,
ctor
:
{
new
(
editor
:
ICommonNotebookEditor
,
...
services
:
Services
):
IOutputTransformContribution
}):
void
{
this
.
outputTransforms
.
push
({
id
:
id
,
ctor
:
ctor
as
IOutputTransformCtor
});
}
getOutputTransformContributions
():
IOutputTransformDescription
[]
{
...
...
src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts
浏览文件 @
5024a705
...
...
@@ -32,7 +32,7 @@ import { NotebookKernelProviderAssociationRegistry, NotebookViewTypesExtensionRe
import
{
CellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
NotebookTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookTextModel
'
;
import
{
ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER
,
BUILTIN_RENDERER_ID
,
CellEditType
,
CellKind
,
CellOutputKind
,
DisplayOrderKey
,
ICellEditOperation
,
INotebookDecorationRenderOptions
,
INotebookKernelInfo2
,
INotebookKernelProvider
,
INotebookRendererInfo
,
INotebookTextModel
,
IOrderedMimeType
,
IDisplay
OutputDto
,
mimeTypeIsAlwaysSecure
,
mimeTypeSupportedByCore
,
notebookDocumentFilterMatch
,
NotebookEditorPriority
,
NOTEBOOK_DISPLAY_ORDER
,
RENDERER_NOT_AVAILABLE
,
sortMimeTypes
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER
,
BUILTIN_RENDERER_ID
,
CellEditType
,
CellKind
,
DisplayOrderKey
,
ICellEditOperation
,
INotebookDecorationRenderOptions
,
INotebookKernelInfo2
,
INotebookKernelProvider
,
INotebookRendererInfo
,
INotebookTextModel
,
IOrderedMimeType
,
I
OutputDto
,
mimeTypeIsAlwaysSecure
,
mimeTypeSupportedByCore
,
notebookDocumentFilterMatch
,
NotebookEditorPriority
,
NOTEBOOK_DISPLAY_ORDER
,
RENDERER_NOT_AVAILABLE
,
sortMimeTypes
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
NotebookOutputRendererInfo
}
from
'
vs/workbench/contrib/notebook/common/notebookOutputRenderer
'
;
import
{
NotebookEditorDescriptor
,
NotebookProviderInfo
}
from
'
vs/workbench/contrib/notebook/common/notebookProvider
'
;
import
{
IMainNotebookController
,
INotebookService
}
from
'
vs/workbench/contrib/notebook/common/notebookService
'
;
...
...
@@ -500,14 +500,11 @@ export class NotebookService extends Disposable implements INotebookService, ICu
language
:
cell
.
language
,
cellKind
:
cell
.
cellKind
,
outputs
:
cell
.
outputs
.
map
(
output
=>
{
if
(
output
.
outputKind
===
CellOutputKind
.
Rich
)
{
return
{
...
output
,
outputId
:
UUID
.
generateUuid
()
};
}
return
output
;
return
{
...
output
,
// paste should generate new outputId
outputId
:
UUID
.
generateUuid
()
};
}),
metadata
:
{
editable
:
cell
.
metadata
?.
editable
,
...
...
@@ -539,14 +536,10 @@ export class NotebookService extends Disposable implements INotebookService, ICu
language
:
cell
.
language
,
cellKind
:
cell
.
cellKind
,
outputs
:
cell
.
outputs
.
map
(
output
=>
{
if
(
output
.
outputKind
===
CellOutputKind
.
Rich
)
{
return
{
...
output
,
outputId
:
UUID
.
generateUuid
()
};
}
return
output
;
return
{
...
output
,
outputId
:
UUID
.
generateUuid
()
};
}),
metadata
:
{
editable
:
cell
.
metadata
?.
editable
,
...
...
@@ -800,17 +793,12 @@ export class NotebookService extends Disposable implements INotebookService, ICu
return
Iterable
.
map
(
this
.
_models
.
values
(),
data
=>
data
.
model
);
}
getMimeTypeInfo
(
textModel
:
NotebookTextModel
,
output
:
I
Display
OutputDto
):
readonly
IOrderedMimeType
[]
{
getMimeTypeInfo
(
textModel
:
NotebookTextModel
,
output
:
IOutputDto
):
readonly
IOrderedMimeType
[]
{
// TODO@rebornix no string[] casting
return
this
.
_getOrderedMimeTypes
(
textModel
,
output
,
textModel
.
metadata
.
displayOrder
as
string
[]
??
[]);
}
private
_getOrderedMimeTypes
(
textModel
:
NotebookTextModel
,
output
:
IDisplayOutputDto
,
documentDisplayOrder
:
string
[]):
IOrderedMimeType
[]
{
if
(
output
.
outputKind
!==
CellOutputKind
.
Rich
)
{
// TODO@rebornix at the end we only have one output
return
[];
}
private
_getOrderedMimeTypes
(
textModel
:
NotebookTextModel
,
output
:
IOutputDto
,
documentDisplayOrder
:
string
[]):
IOrderedMimeType
[]
{
const
mimeTypes
=
Object
.
keys
(
output
.
data
);
const
coreDisplayOrder
=
this
.
_displayOrder
;
const
sorted
=
sortMimeTypes
(
mimeTypes
,
coreDisplayOrder
?.
userOrder
||
[],
documentDisplayOrder
,
coreDisplayOrder
?.
defaultOrder
||
[]);
...
...
src/vs/workbench/contrib/notebook/browser/view/output/outputRenderer.ts
浏览文件 @
5024a705
...
...
@@ -11,14 +11,14 @@ import { URI } from 'vs/base/common/uri';
export
class
OutputRenderer
{
protected
readonly
_contributions
:
{
[
key
:
string
]:
IOutputTransformContribution
;
};
protected
readonly
_
mimeTypeMapping
:
{
[
key
:
number
]:
IOutputTransformContribution
;
}
;
protected
readonly
_
renderers
:
IOutputTransformContribution
[]
;
constructor
(
notebookEditor
:
ICommonNotebookEditor
,
private
readonly
instantiationService
:
IInstantiationService
)
{
this
.
_contributions
=
{};
this
.
_
mimeTypeMapping
=
{}
;
this
.
_
renderers
=
[]
;
const
contributions
=
NotebookRegistry
.
getOutputTransformContributions
();
...
...
@@ -26,7 +26,7 @@ export class OutputRenderer {
try
{
const
contribution
=
this
.
instantiationService
.
createInstance
(
desc
.
ctor
,
notebookEditor
);
this
.
_contributions
[
desc
.
id
]
=
contribution
;
this
.
_
mimeTypeMapping
[
desc
.
kind
]
=
contribution
;
this
.
_
renderers
.
push
(
contribution
)
;
}
catch
(
err
)
{
onUnexpectedError
(
err
);
}
...
...
@@ -34,17 +34,15 @@ export class OutputRenderer {
}
renderNoop
(
viewModel
:
ICellOutputViewModel
,
container
:
HTMLElement
):
IRenderOutput
{
const
output
=
viewModel
.
model
;
const
contentNode
=
document
.
createElement
(
'
p
'
);
contentNode
.
innerText
=
`No renderer could be found for output.
It has the following output type:
${
output
.
outputKind
}
`
;
contentNode
.
innerText
=
`No renderer could be found for output.`
;
container
.
appendChild
(
contentNode
);
return
{
type
:
RenderOutputType
.
None
,
hasDynamicHeight
:
false
};
}
render
(
viewModel
:
ICellOutputViewModel
,
container
:
HTMLElement
,
preferredMimeType
:
string
|
undefined
,
notebookUri
:
URI
|
undefined
):
IRenderOutput
{
const
output
=
viewModel
.
model
;
const
transform
=
this
.
_mimeTypeMapping
[
output
.
outputKind
];
const
transform
=
this
.
_renderers
[
0
];
if
(
transform
)
{
return
transform
.
render
(
viewModel
,
container
,
preferredMimeType
,
notebookUri
);
...
...
src/vs/workbench/contrib/notebook/browser/view/output/transforms/richTransform.ts
浏览文件 @
5024a705
...
...
@@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
CellOutputKind
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
NotebookRegistry
}
from
'
vs/workbench/contrib/notebook/browser/notebookRegistry
'
;
import
*
as
DOM
from
'
vs/base/browser/dom
'
;
import
{
ICellOutputViewModel
,
ICommonNotebookEditor
,
IOutputTransformContribution
,
IRenderOutput
,
RenderOutputType
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
...
...
@@ -238,7 +237,7 @@ class RichRenderer implements IOutputTransformContribution {
}
NotebookRegistry
.
registerOutputTransform
(
'
notebook.output.rich
'
,
CellOutputKind
.
Rich
,
RichRenderer
);
NotebookRegistry
.
registerOutputTransform
(
'
notebook.output.rich
'
,
RichRenderer
);
export
function
getOutputSimpleEditorOptions
():
IEditorOptions
{
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
浏览文件 @
5024a705
...
...
@@ -20,7 +20,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import
{
ICellOutputViewModel
,
ICommonCellInfo
,
ICommonNotebookEditor
,
IDisplayOutputLayoutUpdateRequest
,
IGenericCellViewModel
,
IInsetRenderOutput
,
RenderOutputType
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
preloadsScriptStr
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads
'
;
import
{
transformWebviewThemeVars
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/webviewThemeMapping
'
;
import
{
CellOutputKind
,
INotebookRendererInfo
,
IDisplay
OutputDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookRendererInfo
,
I
OutputDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookService
}
from
'
vs/workbench/contrib/notebook/common/notebookService
'
;
import
{
IWebviewService
,
WebviewContentPurpose
,
WebviewElement
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
asWebviewUri
}
from
'
vs/workbench/contrib/webview/common/webviewUri
'
;
...
...
@@ -87,7 +87,7 @@ export interface ICreationRequestMessage {
type
:
'
html
'
;
content
:
|
{
type
:
RenderOutputType
.
Html
;
htmlContent
:
string
}
|
{
type
:
RenderOutputType
.
Extension
;
output
:
I
Display
OutputDto
;
mimeType
:
string
};
|
{
type
:
RenderOutputType
.
Extension
;
output
:
IOutputDto
;
mimeType
:
string
};
cellId
:
string
;
outputId
:
string
;
top
:
number
;
...
...
@@ -683,7 +683,6 @@ var requirejs = (function() {
type
:
RenderOutputType
.
Extension
,
mimeType
:
content
.
mimeType
,
output
:
{
outputKind
:
CellOutputKind
.
Rich
,
metadata
:
output
.
metadata
,
data
:
output
.
data
,
outputId
:
output
.
outputId
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/cellEdit.ts
浏览文件 @
5024a705
...
...
@@ -5,7 +5,7 @@
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
CellKind
,
I
Display
OutputDto
,
NotebookCellMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
IOutputDto
,
NotebookCellMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
IResourceUndoRedoElement
,
UndoRedoElementType
}
from
'
vs/platform/undoRedo/common/undoRedo
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
BaseCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel
'
;
...
...
@@ -16,7 +16,7 @@ import { ITextCellEditingDelegate } from 'vs/workbench/contrib/notebook/common/m
export
interface
IViewCellEditingDelegate
extends
ITextCellEditingDelegate
{
createCellViewModel
?(
cell
:
NotebookCellTextModel
):
BaseCellViewModel
;
createCell
?(
index
:
number
,
source
:
string
,
language
:
string
,
type
:
CellKind
,
metadata
:
NotebookCellMetadata
|
undefined
,
outputs
:
I
Display
OutputDto
[]):
BaseCellViewModel
;
createCell
?(
index
:
number
,
source
:
string
,
language
:
string
,
type
:
CellKind
,
metadata
:
NotebookCellMetadata
|
undefined
,
outputs
:
IOutputDto
[]):
BaseCellViewModel
;
}
export
class
JoinCellEdit
implements
IResourceUndoRedoElement
{
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/cellOutputViewModel.ts
浏览文件 @
5024a705
...
...
@@ -6,13 +6,13 @@
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ICellOutputViewModel
,
IGenericCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
NotebookTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookTextModel
'
;
import
{
IOrderedMimeType
,
I
Display
OutputDto
,
RENDERER_NOT_AVAILABLE
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
IOrderedMimeType
,
IOutputDto
,
RENDERER_NOT_AVAILABLE
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookService
}
from
'
vs/workbench/contrib/notebook/common/notebookService
'
;
let
handle
=
0
;
export
class
CellOutputViewModel
extends
Disposable
implements
ICellOutputViewModel
{
outputHandle
=
handle
++
;
get
model
():
I
Display
OutputDto
{
get
model
():
IOutputDto
{
return
this
.
_outputRawData
;
}
...
...
@@ -27,7 +27,7 @@ export class CellOutputViewModel extends Disposable implements ICellOutputViewMo
constructor
(
readonly
cellViewModel
:
IGenericCellViewModel
,
private
readonly
_outputRawData
:
I
Display
OutputDto
,
private
readonly
_outputRawData
:
IOutputDto
,
private
readonly
_notebookService
:
INotebookService
)
{
super
();
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts
浏览文件 @
5024a705
...
...
@@ -23,7 +23,7 @@ import { NotebookEventDispatcher, NotebookMetadataChangedEvent } from 'vs/workbe
import
{
CellFoldingState
,
EditorFoldingStateDelegate
}
from
'
vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel
'
;
import
{
MarkdownCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
CellKind
,
NotebookCellMetadata
,
INotebookSearchOptions
,
ICellRange
,
NotebookCellsChangeType
,
ICell
,
NotebookCellTextModelSplice
,
CellEditType
,
I
Display
OutputDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
NotebookCellMetadata
,
INotebookSearchOptions
,
ICellRange
,
NotebookCellsChangeType
,
ICell
,
NotebookCellTextModelSplice
,
CellEditType
,
IOutputDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
FoldingRegions
}
from
'
vs/editor/contrib/folding/foldingRanges
'
;
import
{
NotebookTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookTextModel
'
;
import
{
MarkdownRenderer
}
from
'
vs/editor/browser/core/markdownRenderer
'
;
...
...
@@ -649,7 +649,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
return
result
;
}
createCell
(
index
:
number
,
source
:
string
,
language
:
string
,
type
:
CellKind
,
metadata
:
NotebookCellMetadata
|
undefined
,
outputs
:
I
Display
OutputDto
[],
synchronous
:
boolean
,
pushUndoStop
:
boolean
=
true
,
previouslyFocused
:
ICellViewModel
[]
=
[]):
CellViewModel
{
createCell
(
index
:
number
,
source
:
string
,
language
:
string
,
type
:
CellKind
,
metadata
:
NotebookCellMetadata
|
undefined
,
outputs
:
IOutputDto
[],
synchronous
:
boolean
,
pushUndoStop
:
boolean
=
true
,
previouslyFocused
:
ICellViewModel
[]
=
[]):
CellViewModel
{
const
beforeSelections
=
previouslyFocused
.
map
(
e
=>
e
.
handle
);
this
.
_notebook
.
applyEdits
(
this
.
_notebook
.
versionId
,
[
{
...
...
src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts
浏览文件 @
5024a705
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
ICell
,
NotebookCellOutputsSplice
,
CellKind
,
NotebookCellMetadata
,
NotebookDocumentMetadata
,
TransientOptions
,
I
Display
OutputDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
ICell
,
NotebookCellOutputsSplice
,
CellKind
,
NotebookCellMetadata
,
NotebookDocumentMetadata
,
TransientOptions
,
IOutputDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
PieceTreeTextBufferBuilder
}
from
'
vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
*
as
model
from
'
vs/editor/common/model
'
;
...
...
@@ -27,9 +27,9 @@ export class NotebookCellTextModel extends Disposable implements ICell {
private
_onDidChangeLanguage
=
new
Emitter
<
string
>
();
onDidChangeLanguage
:
Event
<
string
>
=
this
.
_onDidChangeLanguage
.
event
;
private
_outputs
:
I
Display
OutputDto
[];
private
_outputs
:
IOutputDto
[];
get
outputs
():
I
Display
OutputDto
[]
{
get
outputs
():
IOutputDto
[]
{
return
this
.
_outputs
;
}
...
...
@@ -86,7 +86,7 @@ export class NotebookCellTextModel extends Disposable implements ICell {
private
_source
:
string
,
private
_language
:
string
,
public
cellKind
:
CellKind
,
outputs
:
I
Display
OutputDto
[],
outputs
:
IOutputDto
[],
metadata
:
NotebookCellMetadata
|
undefined
,
public
readonly
transientOptions
:
TransientOptions
,
private
readonly
_modelService
:
ITextModelService
...
...
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
浏览文件 @
5024a705
...
...
@@ -7,7 +7,7 @@ import { Emitter, Event } from 'vs/base/common/event';
import
{
Disposable
,
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
INotebookTextModel
,
NotebookCellOutputsSplice
,
NotebookDocumentMetadata
,
NotebookCellMetadata
,
ICellEditOperation
,
CellEditType
,
CellUri
,
notebookDocumentMetadataDefaults
,
diff
,
NotebookCellsChangeType
,
ICellDto2
,
TransientOptions
,
NotebookTextModelChangedEvent
,
NotebookRawContentEvent
,
CellOutputKind
,
IDisplay
OutputDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookTextModel
,
NotebookCellOutputsSplice
,
NotebookDocumentMetadata
,
NotebookCellMetadata
,
ICellEditOperation
,
CellEditType
,
CellUri
,
notebookDocumentMetadataDefaults
,
diff
,
NotebookCellsChangeType
,
ICellDto2
,
TransientOptions
,
NotebookTextModelChangedEvent
,
NotebookRawContentEvent
,
I
OutputDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
ITextSnapshot
}
from
'
vs/editor/common/model
'
;
import
{
IUndoRedoService
,
UndoRedoElementType
,
IUndoRedoElement
,
IResourceUndoRedoElement
,
UndoRedoGroup
,
IWorkspaceUndoRedoElement
}
from
'
vs/platform/undoRedo/common/undoRedo
'
;
import
{
MoveCellEdit
,
SpliceCellsEdit
,
CellMetadataEdit
}
from
'
vs/workbench/contrib/notebook/common/model/cellEdit
'
;
...
...
@@ -649,7 +649,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
this
.
_eventEmitter
.
emit
({
kind
:
NotebookCellsChangeType
.
ChangeLanguage
,
index
:
this
.
_cells
.
indexOf
(
cell
),
language
:
languageId
,
transient
:
false
},
true
);
}
private
_spliceNotebookCellOutputs2
(
cellHandle
:
number
,
outputs
:
I
Display
OutputDto
[],
computeUndoRedo
:
boolean
):
void
{
private
_spliceNotebookCellOutputs2
(
cellHandle
:
number
,
outputs
:
IOutputDto
[],
computeUndoRedo
:
boolean
):
void
{
const
cell
=
this
.
_mapping
.
get
(
cellHandle
);
if
(
!
cell
)
{
return
;
...
...
@@ -702,19 +702,12 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
}
class
OutputSequence
implements
ISequence
{
constructor
(
readonly
outputs
:
I
Display
OutputDto
[])
{
constructor
(
readonly
outputs
:
IOutputDto
[])
{
}
getElements
():
Int32Array
|
number
[]
|
string
[]
{
return
this
.
outputs
.
map
(
output
=>
{
switch
(
output
.
outputKind
)
{
case
CellOutputKind
.
Rich
:
return
hash
([
output
.
outputKind
,
output
.
metadata
,
output
.
data
]);
// case CellOutputKind.Error:
// return hash([output.outputKind, output.ename, output.evalue, output.traceback]);
// case CellOutputKind.Text:
// return hash([output.outputKind, output.text]);
}
return
hash
([
output
.
metadata
,
output
.
data
]);
});
}
...
...
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
浏览文件 @
5024a705
...
...
@@ -29,12 +29,6 @@ export enum CellKind {
Code
=
2
}
export
enum
CellOutputKind
{
Text
=
1
,
Error
=
2
,
Rich
=
3
}
export
const
NOTEBOOK_DISPLAY_ORDER
=
[
'
application/json
'
,
'
application/javascript
'
,
...
...
@@ -152,8 +146,7 @@ export interface IOrderedMimeType {
isTrusted
:
boolean
;
}
export
interface
IDisplayOutputDto
{
outputKind
:
CellOutputKind
.
Rich
;
export
interface
IOutputDto
{
/**
* { mime_type: value }
*/
...
...
@@ -169,7 +162,7 @@ export interface ICell {
handle
:
number
;
language
:
string
;
cellKind
:
CellKind
;
outputs
:
I
Display
OutputDto
[];
outputs
:
IOutputDto
[];
metadata
?:
NotebookCellMetadata
;
onDidChangeOutputs
?:
Event
<
NotebookCellOutputsSplice
[]
>
;
onDidChangeLanguage
:
Event
<
string
>
;
...
...
@@ -203,7 +196,7 @@ export type NotebookCellTextModelSplice<T> = [
export
type
NotebookCellOutputsSplice
=
[
start
:
number
/* start */
,
deleteCount
:
number
/* delete count */
,
newOutputs
:
I
Display
OutputDto
[]
newOutputs
:
IOutputDto
[]
];
export
interface
IMainCellDto
{
...
...
@@ -213,7 +206,7 @@ export interface IMainCellDto {
eol
:
string
;
language
:
string
;
cellKind
:
CellKind
;
outputs
:
I
Display
OutputDto
[];
outputs
:
IOutputDto
[];
metadata
?:
NotebookCellMetadata
;
}
...
...
@@ -262,7 +255,7 @@ export interface NotebookCellsModelMoveEvent<T> {
export
interface
NotebookOutputChangedEvent
{
readonly
kind
:
NotebookCellsChangeType
.
Output
;
readonly
index
:
number
;
readonly
outputs
:
I
Display
OutputDto
[];
readonly
outputs
:
IOutputDto
[];
}
export
interface
NotebookCellsChangeLanguageEvent
{
...
...
@@ -317,7 +310,7 @@ export interface ICellDto2 {
source
:
string
;
language
:
string
;
cellKind
:
CellKind
;
outputs
:
I
Display
OutputDto
[];
outputs
:
IOutputDto
[];
metadata
?:
NotebookCellMetadata
;
}
...
...
@@ -331,7 +324,7 @@ export interface ICellReplaceEdit {
export
interface
ICellOutputEdit
{
editType
:
CellEditType
.
Output
;
index
:
number
;
outputs
:
I
Display
OutputDto
[];
outputs
:
IOutputDto
[];
append
?:
boolean
}
...
...
src/vs/workbench/contrib/notebook/common/notebookService.ts
浏览文件 @
5024a705
...
...
@@ -10,7 +10,7 @@ import { NotebookExtensionDescription } from 'vs/workbench/api/common/extHost.pr
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
INotebookTextModel
,
INotebookRendererInfo
,
IEditor
,
INotebookKernelProvider
,
INotebookKernelInfo2
,
TransientMetadata
,
NotebookDataDto
,
TransientOptions
,
INotebookDecorationRenderOptions
,
INotebookExclusiveDocumentFilter
,
IOrderedMimeType
,
I
Display
OutputDto
IEditor
,
INotebookKernelProvider
,
INotebookKernelInfo2
,
TransientMetadata
,
NotebookDataDto
,
TransientOptions
,
INotebookDecorationRenderOptions
,
INotebookExclusiveDocumentFilter
,
IOrderedMimeType
,
IOutputDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
NotebookTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookTextModel
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
...
...
@@ -49,7 +49,7 @@ export interface INotebookService {
onDidChangeNotebookActiveKernel
:
Event
<
{
uri
:
URI
,
providerHandle
:
number
|
undefined
,
kernelFriendlyId
:
string
|
undefined
;
}
>
;
registerNotebookController
(
viewType
:
string
,
extensionData
:
NotebookExtensionDescription
,
controller
:
IMainNotebookController
):
IDisposable
;
getMimeTypeInfo
(
textModel
:
NotebookTextModel
,
output
:
I
Display
OutputDto
):
readonly
IOrderedMimeType
[];
getMimeTypeInfo
(
textModel
:
NotebookTextModel
,
output
:
IOutputDto
):
readonly
IOrderedMimeType
[];
registerNotebookKernelProvider
(
provider
:
INotebookKernelProvider
):
IDisposable
;
getContributedNotebookKernels
(
viewType
:
string
,
resource
:
URI
,
token
:
CancellationToken
):
Promise
<
INotebookKernelInfo2
[]
>
;
...
...
src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.ts
浏览文件 @
5024a705
...
...
@@ -9,7 +9,7 @@ import { URI } from 'vs/base/common/uri';
import
{
IRequestHandler
}
from
'
vs/base/common/worker/simpleWorker
'
;
import
*
as
model
from
'
vs/editor/common/model
'
;
import
{
PieceTreeTextBufferBuilder
}
from
'
vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder
'
;
import
{
CellKind
,
ICellDto2
,
IMainCellDto
,
INotebookDiffResult
,
I
Display
OutputDto
,
NotebookCellMetadata
,
NotebookCellsChangedEventDto
,
NotebookCellsChangeType
,
NotebookCellsSplice2
,
NotebookDataDto
,
NotebookDocumentMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
ICellDto2
,
IMainCellDto
,
INotebookDiffResult
,
IOutputDto
,
NotebookCellMetadata
,
NotebookCellsChangedEventDto
,
NotebookCellsChangeType
,
NotebookCellsSplice2
,
NotebookDataDto
,
NotebookDocumentMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
EditorWorkerHost
}
from
'
vs/workbench/contrib/notebook/common/services/notebookWorkerServiceImpl
'
;
...
...
@@ -45,7 +45,7 @@ class MirrorCell {
private
_source
:
string
|
string
[],
public
language
:
string
,
public
cellKind
:
CellKind
,
public
outputs
:
I
Display
OutputDto
[],
public
outputs
:
IOutputDto
[],
public
metadata
?:
NotebookCellMetadata
)
{
}
...
...
src/vs/workbench/contrib/notebook/test/notebookTextModel.test.ts
浏览文件 @
5024a705
...
...
@@ -4,12 +4,11 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
{
CellKind
,
CellEditType
,
CellOutputKind
,
NotebookTextModelChangedEvent
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
CellEditType
,
NotebookTextModelChangedEvent
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
withTestNotebook
,
TestCell
,
setupInstantiationService
}
from
'
vs/workbench/contrib/notebook/test/testNotebookEditor
'
;
import
{
IBulkEditService
}
from
'
vs/editor/browser/services/bulkEditService
'
;
import
{
IUndoRedoService
}
from
'
vs/platform/undoRedo/common/undoRedo
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
assertType
}
from
'
vs/base/common/types
'
;
suite
(
'
NotebookTextModel
'
,
()
=>
{
const
instantiationService
=
setupInstantiationService
();
...
...
@@ -197,7 +196,6 @@ suite('NotebookTextModel', () => {
index
:
0
,
editType
:
CellEditType
.
Output
,
outputs
:
[{
outputKind
:
CellOutputKind
.
Rich
,
outputId
:
'
someId
'
,
data
:
{
'
text/markdown
'
:
'
_Hello_
'
}
}]
...
...
@@ -205,7 +203,6 @@ suite('NotebookTextModel', () => {
assert
.
strictEqual
(
textModel
.
cells
.
length
,
1
);
assert
.
strictEqual
(
textModel
.
cells
[
0
].
outputs
.
length
,
1
);
assert
.
strictEqual
(
textModel
.
cells
[
0
].
outputs
[
0
].
outputKind
,
CellOutputKind
.
Rich
);
// append
textModel
.
applyEdits
(
textModel
.
versionId
,
[{
...
...
@@ -213,7 +210,6 @@ suite('NotebookTextModel', () => {
editType
:
CellEditType
.
Output
,
append
:
true
,
outputs
:
[{
outputKind
:
CellOutputKind
.
Rich
,
outputId
:
'
someId2
'
,
data
:
{
'
text/markdown
'
:
'
_Hello2_
'
}
}]
...
...
@@ -222,8 +218,6 @@ suite('NotebookTextModel', () => {
assert
.
strictEqual
(
textModel
.
cells
.
length
,
1
);
assert
.
strictEqual
(
textModel
.
cells
[
0
].
outputs
.
length
,
2
);
let
[
first
,
second
]
=
textModel
.
cells
[
0
].
outputs
;
assertType
(
first
.
outputKind
===
CellOutputKind
.
Rich
);
assertType
(
second
.
outputKind
===
CellOutputKind
.
Rich
);
assert
.
strictEqual
(
first
.
outputId
,
'
someId
'
);
assert
.
strictEqual
(
second
.
outputId
,
'
someId2
'
);
...
...
@@ -232,7 +226,6 @@ suite('NotebookTextModel', () => {
index
:
0
,
editType
:
CellEditType
.
Output
,
outputs
:
[{
outputKind
:
CellOutputKind
.
Rich
,
outputId
:
'
someId3
'
,
data
:
{
'
text/plain
'
:
'
Last, replaced output
'
}
}]
...
...
@@ -241,7 +234,6 @@ suite('NotebookTextModel', () => {
assert
.
strictEqual
(
textModel
.
cells
.
length
,
1
);
assert
.
strictEqual
(
textModel
.
cells
[
0
].
outputs
.
length
,
1
);
[
first
]
=
textModel
.
cells
[
0
].
outputs
;
assertType
(
first
.
outputKind
===
CellOutputKind
.
Rich
);
assert
.
strictEqual
(
first
.
outputId
,
'
someId3
'
);
}
);
...
...
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
浏览文件 @
5024a705
...
...
@@ -18,7 +18,7 @@ import { NotebookEventDispatcher } from 'vs/workbench/contrib/notebook/browser/v
import
{
CellViewModel
,
IModelDecorationsChangeAccessor
,
NotebookViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
NotebookTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookTextModel
'
;
import
{
CellKind
,
CellUri
,
INotebookEditorModel
,
NotebookCellMetadata
,
ICellRange
,
INotebookKernelInfo2
,
notebookDocumentMetadataDefaults
,
I
Display
OutputDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
CellUri
,
INotebookEditorModel
,
NotebookCellMetadata
,
ICellRange
,
INotebookKernelInfo2
,
notebookDocumentMetadataDefaults
,
IOutputDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
Webview
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
ICompositeCodeEditor
,
IEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
NotImplementedError
}
from
'
vs/base/common/errors
'
;
...
...
@@ -44,7 +44,7 @@ export class TestCell extends NotebookCellTextModel {
public
source
:
string
,
language
:
string
,
cellKind
:
CellKind
,
outputs
:
I
Display
OutputDto
[],
outputs
:
IOutputDto
[],
modelService
:
ITextModelService
)
{
super
(
CellUri
.
generate
(
URI
.
parse
(
'
test:///fake/notebook
'
),
handle
),
handle
,
source
,
language
,
cellKind
,
outputs
,
undefined
,
{
transientMetadata
:
{},
transientOutputs
:
false
},
modelService
);
...
...
@@ -421,7 +421,7 @@ export function setupInstantiationService() {
return
instantiationService
;
}
export
function
withTestNotebook
(
instantiationService
:
TestInstantiationService
,
blukEditService
:
IBulkEditService
,
undoRedoService
:
IUndoRedoService
,
cells
:
[
string
,
string
,
CellKind
,
I
Display
OutputDto
[],
NotebookCellMetadata
][],
callback
:
(
editor
:
TestNotebookEditor
,
viewModel
:
NotebookViewModel
,
textModel
:
NotebookTextModel
)
=>
void
)
{
export
function
withTestNotebook
(
instantiationService
:
TestInstantiationService
,
blukEditService
:
IBulkEditService
,
undoRedoService
:
IUndoRedoService
,
cells
:
[
string
,
string
,
CellKind
,
IOutputDto
[],
NotebookCellMetadata
][],
callback
:
(
editor
:
TestNotebookEditor
,
viewModel
:
NotebookViewModel
,
textModel
:
NotebookTextModel
)
=>
void
)
{
const
textModelService
=
instantiationService
.
get
(
ITextModelService
);
const
modeService
=
instantiationService
.
get
(
IModeService
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录