Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
2249f2ab
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,发现更多精彩内容 >>
提交
2249f2ab
编写于
10月 09, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #108406. openNotebookDocument.
上级
ec83474a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
79 addition
and
2 deletion
+79
-2
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+1
-0
src/vs/workbench/api/browser/mainThreadNotebook.ts
src/vs/workbench/api/browser/mainThreadNotebook.ts
+61
-2
src/vs/workbench/api/common/extHost.api.impl.ts
src/vs/workbench/api/common/extHost.api.impl.ts
+4
-0
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+1
-0
src/vs/workbench/api/common/extHostNotebook.ts
src/vs/workbench/api/common/extHostNotebook.ts
+12
-0
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
2249f2ab
...
...
@@ -1841,6 +1841,7 @@ declare module 'vscode' {
):
Disposable
;
export
function
createNotebookEditorDecorationType
(
options
:
NotebookDecorationRenderOptions
):
NotebookEditorDecorationType
;
export
function
openNotebookDocument
(
uri
:
Uri
,
viewType
?:
string
):
Promise
<
NotebookDocument
>
;
export
const
onDidOpenNotebookDocument
:
Event
<
NotebookDocument
>
;
export
const
onDidCloseNotebookDocument
:
Event
<
NotebookDocument
>
;
export
const
onDidSaveNotebookDocument
:
Event
<
NotebookDocument
>
;
...
...
src/vs/workbench/api/browser/mainThreadNotebook.ts
浏览文件 @
2249f2ab
...
...
@@ -7,9 +7,10 @@ import * as DOM from 'vs/base/browser/dom';
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IRelativePattern
}
from
'
vs/base/common/glob
'
;
import
{
combinedDisposable
,
Disposable
,
DisposableStore
,
IDisposabl
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
combinedDisposable
,
Disposable
,
DisposableStore
,
dispose
,
IDisposable
,
IReferenc
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
ResourceMap
}
from
'
vs/base/common/map
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IExtUri
}
from
'
vs/base/common/resources
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
IAccessibilityService
}
from
'
vs/platform/accessibility/common/accessibility
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -19,9 +20,11 @@ import { INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookB
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
NotebookTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookTextModel
'
;
import
{
INotebookCellStatusBarService
}
from
'
vs/workbench/contrib/notebook/common/notebookCellStatusBarService
'
;
import
{
ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER
,
CellEditType
,
DisplayOrderKey
,
ICellEditOperation
,
ICellRange
,
IEditor
,
IMainCellDto
,
INotebookDecorationRenderOptions
,
INotebookDocumentFilter
,
INotebookExclusiveDocumentFilter
,
NotebookCellOutputsSplice
,
NotebookCellsChangeType
,
NOTEBOOK_DISPLAY_ORDER
,
TransientMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER
,
CellEditType
,
DisplayOrderKey
,
ICellEditOperation
,
ICellRange
,
IEditor
,
IMainCellDto
,
INotebookDecorationRenderOptions
,
INotebookDocumentFilter
,
INotebookEditorModel
,
INotebookExclusiveDocumentFilter
,
NotebookCellOutputsSplice
,
NotebookCellsChangeType
,
NOTEBOOK_DISPLAY_ORDER
,
TransientMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookEditorModelResolverService
}
from
'
vs/workbench/contrib/notebook/common/notebookEditorModelResolverService
'
;
import
{
IMainNotebookController
,
INotebookService
}
from
'
vs/workbench/contrib/notebook/common/notebookService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IUriIdentityService
}
from
'
vs/workbench/services/uriIdentity/common/uriIdentity
'
;
import
{
IWorkingCopyService
}
from
'
vs/workbench/services/workingCopy/common/workingCopyService
'
;
import
{
ExtHostContext
,
ExtHostNotebookShape
,
IExtHostContext
,
INotebookCellStatusBarEntryDto
,
INotebookDocumentsAndEditorsDelta
,
INotebookModelAddedData
,
MainContext
,
MainThreadNotebookShape
,
NotebookEditorRevealType
,
NotebookExtensionDescription
}
from
'
../common/extHost.protocol
'
;
...
...
@@ -142,6 +145,7 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
private
_editorEventListenersMapping
:
Map
<
string
,
DisposableStore
>
=
new
Map
();
private
_documentEventListenersMapping
:
ResourceMap
<
DisposableStore
>
=
new
ResourceMap
();
private
readonly
_cellStatusBarEntries
:
Map
<
number
,
IDisposable
>
=
new
Map
();
private
readonly
_modelReferenceCollection
:
BoundModelReferenceCollection
;
constructor
(
extHostContext
:
IExtHostContext
,
...
...
@@ -152,9 +156,13 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
@
ILogService
private
readonly
logService
:
ILogService
,
@
INotebookCellStatusBarService
private
readonly
cellStatusBarService
:
INotebookCellStatusBarService
,
@
IWorkingCopyService
private
readonly
_workingCopyService
:
IWorkingCopyService
,
@
INotebookEditorModelResolverService
private
readonly
_notebookModelResolverService
:
INotebookEditorModelResolverService
,
@
IUriIdentityService
private
readonly
_uriIdentityService
:
IUriIdentityService
,
)
{
super
();
this
.
_proxy
=
extHostContext
.
getProxy
(
ExtHostContext
.
ExtHostNotebook
);
this
.
_modelReferenceCollection
=
new
BoundModelReferenceCollection
(
this
.
_uriIdentityService
.
extUri
);
this
.
_register
(
this
.
_modelReferenceCollection
);
this
.
registerListeners
();
}
...
...
@@ -709,4 +717,55 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
this
.
cellStatusBarService
.
addEntry
(
statusBarEntry
));
}
}
async
$tryOpenDocument
(
uriComponents
:
UriComponents
,
viewType
?:
string
):
Promise
<
URI
>
{
const
uri
=
URI
.
revive
(
uriComponents
);
const
ref
=
await
this
.
_notebookModelResolverService
.
resolve
(
uri
,
viewType
);
this
.
_modelReferenceCollection
.
add
(
uri
,
ref
);
return
uri
;
}
}
export
class
BoundModelReferenceCollection
{
private
_data
=
new
Array
<
{
uri
:
URI
,
dispose
():
void
}
>
();
constructor
(
private
readonly
_extUri
:
IExtUri
,
private
readonly
_maxAge
:
number
=
1000
*
60
*
3
,
)
{
//
}
dispose
():
void
{
this
.
_data
=
dispose
(
this
.
_data
);
}
remove
(
uri
:
URI
):
void
{
for
(
const
entry
of
[...
this
.
_data
]
/* copy array because dispose will modify it */
)
{
if
(
this
.
_extUri
.
isEqualOrParent
(
entry
.
uri
,
uri
))
{
entry
.
dispose
();
}
}
}
add
(
uri
:
URI
,
ref
:
IReference
<
INotebookEditorModel
>
):
void
{
let
handle
:
any
;
let
entry
:
{
uri
:
URI
,
dispose
():
void
};
const
dispose
=
()
=>
{
const
idx
=
this
.
_data
.
indexOf
(
entry
);
if
(
idx
>=
0
)
{
ref
.
dispose
();
clearTimeout
(
handle
);
this
.
_data
.
splice
(
idx
,
1
);
}
};
handle
=
setTimeout
(
dispose
,
this
.
_maxAge
);
entry
=
{
uri
,
dispose
};
this
.
_data
.
push
(
entry
);
}
}
src/vs/workbench/api/common/extHost.api.impl.ts
浏览文件 @
2249f2ab
...
...
@@ -967,6 +967,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
onDidChangeNotebookEditorSelection
:
Event
<
vscode
.
NotebookEditorSelectionChangeEvent
>
;
onDidChangeNotebookEditorVisibleRanges
:
Event
<
vscode
.
NotebookEditorVisibleRangesChangeEvent
>
;
})
=
{
openNotebookDocument
:
(
uriComponents
,
viewType
)
=>
{
checkProposedApiEnabled
(
extension
);
return
extHostNotebook
.
openNotebookDocument
(
uriComponents
,
viewType
);
},
get
onDidOpenNotebookDocument
():
Event
<
vscode
.
NotebookDocument
>
{
checkProposedApiEnabled
(
extension
);
return
extHostNotebook
.
onDidOpenNotebookDocument
;
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
2249f2ab
...
...
@@ -755,6 +755,7 @@ export interface MainThreadNotebookShape extends IDisposable {
$spliceNotebookCellOutputs
(
viewType
:
string
,
resource
:
UriComponents
,
cellHandle
:
number
,
splices
:
NotebookCellOutputsSplice
[]):
Promise
<
void
>
;
$postMessage
(
editorId
:
string
,
forRendererId
:
string
|
undefined
,
value
:
any
):
Promise
<
boolean
>
;
$setStatusBarEntry
(
id
:
number
,
statusBarEntry
:
INotebookCellStatusBarEntryDto
):
Promise
<
void
>
;
$tryOpenDocument
(
uriComponents
:
UriComponents
,
viewType
?:
string
):
Promise
<
URI
>
;
$tryRevealRange
(
id
:
string
,
range
:
ICellRange
,
revealType
:
NotebookEditorRevealType
):
Promise
<
void
>
;
$registerNotebookEditorDecorationType
(
key
:
string
,
options
:
INotebookDecorationRenderOptions
):
void
;
$removeNotebookEditorDecorationType
(
key
:
string
):
void
;
...
...
src/vs/workbench/api/common/extHostNotebook.ts
浏览文件 @
2249f2ab
...
...
@@ -24,6 +24,7 @@ import { ExtHostCell, ExtHostNotebookDocument } from './extHostNotebookDocument'
import
{
ExtHostNotebookEditor
}
from
'
./extHostNotebookEditor
'
;
import
{
IdGenerator
}
from
'
vs/base/common/idGenerator
'
;
import
{
IRelativePattern
}
from
'
vs/base/common/glob
'
;
import
{
assertIsDefined
}
from
'
vs/base/common/types
'
;
class
ExtHostWebviewCommWrapper
extends
Disposable
{
private
readonly
_onDidReceiveDocumentMessage
=
new
Emitter
<
any
>
();
...
...
@@ -386,6 +387,17 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
return
new
NotebookEditorDecorationType
(
this
.
_proxy
,
options
);
}
async
openNotebookDocument
(
uriComponents
:
UriComponents
,
viewType
?:
string
):
Promise
<
vscode
.
NotebookDocument
>
{
const
cached
=
this
.
_documents
.
get
(
URI
.
revive
(
uriComponents
));
if
(
cached
)
{
return
Promise
.
resolve
(
cached
.
notebookDocument
);
}
await
this
.
_proxy
.
$tryOpenDocument
(
uriComponents
,
viewType
);
const
document
=
this
.
_documents
.
get
(
URI
.
revive
(
uriComponents
));
return
assertIsDefined
(
document
?.
notebookDocument
);
}
private
_withAdapter
<
T
>
(
handle
:
number
,
uri
:
UriComponents
,
callback
:
(
adapter
:
ExtHostNotebookKernelProviderAdapter
,
document
:
ExtHostNotebookDocument
)
=>
Promise
<
T
>
)
{
const
document
=
this
.
_documents
.
get
(
URI
.
revive
(
uri
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录