Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
997c9f29
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,发现更多精彩内容 >>
未验证
提交
997c9f29
编写于
3月 05, 2021
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add showNotebookDocument overload or uri
上级
ae2f3e07
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
82 addition
and
7 deletion
+82
-7
extensions/vscode-api-tests/src/singlefolder-tests/notebook.editor.test.ts
...-api-tests/src/singlefolder-tests/notebook.editor.test.ts
+69
-0
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+2
-1
src/vs/workbench/api/common/extHost.api.impl.ts
src/vs/workbench/api/common/extHost.api.impl.ts
+2
-2
src/vs/workbench/api/common/extHostNotebook.ts
src/vs/workbench/api/common/extHostNotebook.ts
+9
-4
未找到文件。
extensions/vscode-api-tests/src/singlefolder-tests/notebook.editor.test.ts
0 → 100644
浏览文件 @
997c9f29
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
*
as
vscode
from
'
vscode
'
;
import
*
as
utils
from
'
../utils
'
;
suite
(
'
Notebook Editor
'
,
function
()
{
const
contentProvider
=
new
class
implements
vscode
.
NotebookContentProvider
{
async
openNotebook
(
uri
:
vscode
.
Uri
,
_openContext
:
vscode
.
NotebookDocumentOpenContext
):
Promise
<
vscode
.
NotebookData
>
{
return
{
cells
:
[{
cellKind
:
vscode
.
NotebookCellKind
.
Code
,
source
:
uri
.
toString
(),
language
:
'
javascript
'
,
metadata
:
new
vscode
.
NotebookCellMetadata
(),
outputs
:
[]
}],
metadata
:
new
vscode
.
NotebookDocumentMetadata
()
};
}
async
resolveNotebook
(
_document
:
vscode
.
NotebookDocument
,
_webview
:
vscode
.
NotebookCommunication
)
{
//
}
async
saveNotebook
(
_document
:
vscode
.
NotebookDocument
,
_cancellation
:
vscode
.
CancellationToken
)
{
//
}
async
saveNotebookAs
(
_targetResource
:
vscode
.
Uri
,
_document
:
vscode
.
NotebookDocument
,
_cancellation
:
vscode
.
CancellationToken
)
{
//
}
async
backupNotebook
(
_document
:
vscode
.
NotebookDocument
,
_context
:
vscode
.
NotebookDocumentBackupContext
,
_cancellation
:
vscode
.
CancellationToken
)
{
return
{
id
:
''
,
delete
()
{
}
};
}
};
const
disposables
:
vscode
.
Disposable
[]
=
[];
suiteTeardown
(
async
function
()
{
utils
.
assertNoRpc
();
await
utils
.
revertAllDirty
();
await
utils
.
closeAllEditors
();
utils
.
disposeAll
(
disposables
);
disposables
.
length
=
0
;
for
(
let
doc
of
vscode
.
notebook
.
notebookDocuments
)
{
assert
.
strictEqual
(
doc
.
isDirty
,
false
,
doc
.
uri
.
toString
());
}
});
suiteSetup
(
function
()
{
disposables
.
push
(
vscode
.
notebook
.
registerNotebookContentProvider
(
'
notebook.nbdtest
'
,
contentProvider
));
});
test
(
'
showNotebookDocment
'
,
async
function
()
{
const
count1
=
vscode
.
notebook
.
notebookDocuments
.
length
;
const
p
=
utils
.
asPromise
(
vscode
.
notebook
.
onDidOpenNotebookDocument
);
const
uri
=
await
utils
.
createRandomFile
(
undefined
,
undefined
,
'
.nbdtest
'
);
const
editor
=
await
vscode
.
window
.
showNotebookDocument
(
uri
);
assert
.
strictEqual
(
uri
.
toString
(),
editor
.
document
.
uri
.
toString
());
const
event
=
await
p
;
assert
.
strictEqual
(
event
.
uri
.
toString
(),
uri
.
toString
());
const
count2
=
vscode
.
notebook
.
notebookDocuments
.
length
;
assert
.
strictEqual
(
count1
+
1
,
count2
);
});
});
src/vs/vscode.proposed.d.ts
浏览文件 @
997c9f29
...
...
@@ -1447,7 +1447,8 @@ declare module 'vscode' {
export
const
onDidChangeActiveNotebookEditor
:
Event
<
NotebookEditor
|
undefined
>
;
export
const
onDidChangeNotebookEditorSelection
:
Event
<
NotebookEditorSelectionChangeEvent
>
;
export
const
onDidChangeNotebookEditorVisibleRanges
:
Event
<
NotebookEditorVisibleRangesChangeEvent
>
;
// TODO@API add overload for just a URI
export
function
showNotebookDocument
(
uri
:
Uri
,
options
?:
NotebookDocumentShowOptions
):
Thenable
<
NotebookEditor
>
;
export
function
showNotebookDocument
(
document
:
NotebookDocument
,
options
?:
NotebookDocumentShowOptions
):
Thenable
<
NotebookEditor
>
;
}
...
...
src/vs/workbench/api/common/extHost.api.impl.ts
浏览文件 @
997c9f29
...
...
@@ -702,9 +702,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
checkProposedApiEnabled
(
extension
);
return
extHostNotebook
.
onDidChangeNotebookEditorVisibleRanges
(
listener
,
thisArgs
,
disposables
);
},
showNotebookDocument
(
d
ocument
,
options
?)
{
showNotebookDocument
(
uriOrD
ocument
,
options
?)
{
checkProposedApiEnabled
(
extension
);
return
extHostNotebook
.
showNotebookDocument
(
d
ocument
,
options
);
return
extHostNotebook
.
showNotebookDocument
(
uriOrD
ocument
,
options
);
},
registerExternalUriOpener
(
id
:
string
,
opener
:
vscode
.
ExternalUriOpener
,
metadata
:
vscode
.
ExternalUriOpenerMetadata
)
{
checkProposedApiEnabled
(
extension
);
...
...
src/vs/workbench/api/common/extHostNotebook.ts
浏览文件 @
997c9f29
...
...
@@ -408,7 +408,12 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
return
callback
(
provider
,
document
);
}
async
showNotebookDocument
(
notebookDocument
:
vscode
.
NotebookDocument
,
options
?:
vscode
.
NotebookDocumentShowOptions
):
Promise
<
vscode
.
NotebookEditor
>
{
async
showNotebookDocument
(
notebookOrUri
:
vscode
.
NotebookDocument
|
URI
,
options
?:
vscode
.
NotebookDocumentShowOptions
):
Promise
<
vscode
.
NotebookEditor
>
{
if
(
URI
.
isUri
(
notebookOrUri
))
{
notebookOrUri
=
await
this
.
openNotebookDocument
(
notebookOrUri
);
}
let
resolvedOptions
:
INotebookDocumentShowOptions
;
if
(
typeof
options
===
'
object
'
)
{
resolvedOptions
=
{
...
...
@@ -423,7 +428,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
};
}
const
editorId
=
await
this
.
_proxy
.
$tryShowNotebookDocument
(
notebook
Document
.
uri
,
notebookDocument
.
viewType
,
resolvedOptions
);
const
editorId
=
await
this
.
_proxy
.
$tryShowNotebookDocument
(
notebook
OrUri
.
uri
,
notebookOrUri
.
viewType
,
resolvedOptions
);
const
editor
=
editorId
&&
this
.
_editors
.
get
(
editorId
)?.
editor
;
if
(
editor
)
{
...
...
@@ -431,9 +436,9 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
}
if
(
editorId
)
{
throw
new
Error
(
`Could NOT open editor for "
${
notebook
Document
.
toString
()}
" because another editor opened in the meantime.`
);
throw
new
Error
(
`Could NOT open editor for "
${
notebook
OrUri
.
toString
()}
" because another editor opened in the meantime.`
);
}
else
{
throw
new
Error
(
`Could NOT open editor for "
${
notebook
Document
.
toString
()}
".`
);
throw
new
Error
(
`Could NOT open editor for "
${
notebook
OrUri
.
toString
()}
".`
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录