Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
3723081d
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,发现更多精彩内容 >>
提交
3723081d
编写于
2月 19, 2021
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
separate vscode.NotebookEditor from ExtHostNotebookEditor
上级
dc120ded
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
62 addition
and
76 deletion
+62
-76
src/vs/workbench/api/common/extHostNotebook.ts
src/vs/workbench/api/common/extHostNotebook.ts
+17
-16
src/vs/workbench/api/common/extHostNotebookEditor.ts
src/vs/workbench/api/common/extHostNotebookEditor.ts
+45
-60
未找到文件。
src/vs/workbench/api/common/extHostNotebook.ts
浏览文件 @
3723081d
...
...
@@ -240,9 +240,12 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
readonly
onDidChangeActiveNotebookEditor
=
this
.
_onDidChangeActiveNotebookEditor
.
event
;
private
_activeNotebookEditor
:
ExtHostNotebookEditor
|
undefined
;
get
activeNotebookEditor
()
{
return
this
.
_activeNotebookEditor
;
get
activeNotebookEditor
():
vscode
.
NotebookEditor
|
undefined
{
return
this
.
_activeNotebookEditor
?.
editor
;
}
private
_visibleNotebookEditors
:
ExtHostNotebookEditor
[]
=
[];
get
visibleNotebookEditors
():
vscode
.
NotebookEditor
[]
{
return
this
.
_visibleNotebookEditors
.
map
(
editor
=>
editor
.
editor
);
}
private
_onDidOpenNotebookDocument
=
new
Emitter
<
vscode
.
NotebookDocument
>
();
...
...
@@ -251,7 +254,6 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
onDidCloseNotebookDocument
:
Event
<
vscode
.
NotebookDocument
>
=
this
.
_onDidCloseNotebookDocument
.
event
;
private
_onDidSaveNotebookDocument
=
new
Emitter
<
vscode
.
NotebookDocument
>
();
onDidSaveNotebookDocument
:
Event
<
vscode
.
NotebookDocument
>
=
this
.
_onDidSaveNotebookDocument
.
event
;
visibleNotebookEditors
:
ExtHostNotebookEditor
[]
=
[];
private
_onDidChangeActiveNotebookKernel
=
new
Emitter
<
{
document
:
vscode
.
NotebookDocument
,
kernel
:
vscode
.
NotebookKernel
|
undefined
;
}
>
();
onDidChangeActiveNotebookKernel
=
this
.
_onDidChangeActiveNotebookKernel
.
event
;
private
_onDidChangeVisibleNotebookEditors
=
new
Emitter
<
vscode
.
NotebookEditor
[]
>
();
...
...
@@ -425,7 +427,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
const
editor
=
editorId
&&
this
.
_editors
.
get
(
editorId
)?.
editor
;
if
(
editor
)
{
return
editor
;
return
editor
.
editor
;
}
if
(
editorId
)
{
...
...
@@ -581,8 +583,8 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
if
(
data
.
visibleRanges
)
{
editor
.
editor
.
_acceptVisibleRanges
(
data
.
visibleRanges
.
ranges
.
map
(
typeConverters
.
NotebookCellRange
.
to
));
this
.
_onDidChangeNotebookEditorVisibleRanges
.
fire
({
notebookEditor
:
editor
.
editor
,
visibleRanges
:
editor
.
editor
.
visibleRanges
notebookEditor
:
editor
.
editor
.
editor
,
visibleRanges
:
editor
.
editor
.
editor
.
visibleRanges
});
}
...
...
@@ -595,7 +597,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
}
this
.
_onDidChangeNotebookEditorSelection
.
fire
({
notebookEditor
:
editor
.
editor
,
notebookEditor
:
editor
.
editor
.
editor
,
selection
:
editor
.
editor
.
selection
});
}
...
...
@@ -620,7 +622,6 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
editorId
,
document
.
notebookDocument
.
viewType
,
this
.
_proxy
,
webComm
.
contentProviderComm
,
document
);
...
...
@@ -653,7 +654,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
}
for
(
const
e
of
this
.
_editors
.
values
())
{
if
(
e
.
editor
.
document
.
uri
.
toString
()
===
revivedUri
.
toString
())
{
if
(
e
.
editor
.
notebookData
.
uri
.
toString
()
===
revivedUri
.
toString
())
{
e
.
editor
.
dispose
();
this
.
_editors
.
delete
(
e
.
editor
.
id
);
editorChanged
=
true
;
...
...
@@ -752,7 +753,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
editorChanged
=
true
;
this
.
_editors
.
delete
(
editorid
);
if
(
this
.
activeNotebookEditor
?.
id
===
editor
.
editor
.
id
)
{
if
(
this
.
_
activeNotebookEditor
?.
id
===
editor
.
editor
.
id
)
{
this
.
_activeNotebookEditor
=
undefined
;
}
...
...
@@ -768,16 +769,16 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
}
if
(
delta
.
visibleEditors
)
{
this
.
visibleNotebookEditors
=
delta
.
visibleEditors
.
map
(
id
=>
this
.
_editors
.
get
(
id
)
!
.
editor
).
filter
(
editor
=>
!!
editor
)
as
ExtHostNotebookEditor
[];
this
.
_
visibleNotebookEditors
=
delta
.
visibleEditors
.
map
(
id
=>
this
.
_editors
.
get
(
id
)
!
.
editor
).
filter
(
editor
=>
!!
editor
)
as
ExtHostNotebookEditor
[];
const
visibleEditorsSet
=
new
Set
<
string
>
();
this
.
visibleNotebookEditors
.
forEach
(
editor
=>
visibleEditorsSet
.
add
(
editor
.
id
));
this
.
_
visibleNotebookEditors
.
forEach
(
editor
=>
visibleEditorsSet
.
add
(
editor
.
id
));
for
(
const
e
of
this
.
_editors
.
values
())
{
const
newValue
=
visibleEditorsSet
.
has
(
e
.
editor
.
id
);
e
.
editor
.
_acceptVisibility
(
newValue
);
}
this
.
visibleNotebookEditors
=
[...
this
.
_editors
.
values
()].
map
(
e
=>
e
.
editor
).
filter
(
e
=>
e
.
visible
);
this
.
_
visibleNotebookEditors
=
[...
this
.
_editors
.
values
()].
map
(
e
=>
e
.
editor
).
filter
(
e
=>
e
.
visible
);
this
.
_onDidChangeVisibleNotebookEditors
.
fire
(
this
.
visibleNotebookEditors
);
}
...
...
@@ -786,7 +787,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
this
.
_activeNotebookEditor
=
this
.
_editors
.
get
(
delta
.
newActiveEditor
)?.
editor
;
this
.
_activeNotebookEditor
?.
_acceptActive
(
true
);
for
(
const
e
of
this
.
_editors
.
values
())
{
if
(
e
.
editor
!==
this
.
activeNotebookEditor
)
{
if
(
e
.
editor
!==
this
.
_
activeNotebookEditor
)
{
e
.
editor
.
_acceptActive
(
false
);
}
}
...
...
@@ -798,7 +799,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
}
}
this
.
_onDidChangeActiveNotebookEditor
.
fire
(
this
.
_activeNotebookEditor
);
this
.
_onDidChangeActiveNotebookEditor
.
fire
(
this
.
_activeNotebookEditor
?.
editor
);
}
}
...
...
src/vs/workbench/api/common/extHostNotebookEditor.ts
浏览文件 @
3723081d
...
...
@@ -5,7 +5,6 @@
import
{
readonly
}
from
'
vs/base/common/errors
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
MainThreadNotebookShape
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
*
as
extHostTypes
from
'
vs/workbench/api/common/extHostTypes
'
;
import
*
as
extHostConverter
from
'
vs/workbench/api/common/extHostTypeConverters
'
;
...
...
@@ -85,7 +84,7 @@ class NotebookEditorCellEditBuilder implements vscode.NotebookEditorEdit {
}
}
export
class
ExtHostNotebookEditor
extends
Disposable
implements
vscode
.
NotebookEditor
{
export
class
ExtHostNotebookEditor
{
//TODO@rebornix noop setter?
selection
?:
vscode
.
NotebookCell
;
...
...
@@ -97,40 +96,61 @@ export class ExtHostNotebookEditor extends Disposable implements vscode.Notebook
private
_kernel
?:
vscode
.
NotebookKernel
;
private
_onDidDispose
=
new
Emitter
<
void
>
();
private
_onDidReceiveMessage
=
new
Emitter
<
any
>
();
readonly
onDidDispose
:
Event
<
void
>
=
this
.
_onDidDispose
.
event
;
readonly
onDidReceiveMessage
:
vscode
.
Event
<
any
>
=
this
.
_onDidReceiveMessage
.
event
;
private
_hasDecorationsForKey
:
{
[
key
:
string
]:
boolean
;
}
=
Object
.
create
(
null
);
private
_editor
:
vscode
.
NotebookEditor
|
undefined
;
constructor
(
readonly
id
:
string
,
private
readonly
_viewType
:
string
,
private
readonly
_proxy
:
MainThreadNotebookShape
,
private
readonly
_webComm
:
vscode
.
NotebookCommunication
,
readonly
notebookData
:
ExtHostNotebookDocument
,
)
{
super
();
this
.
_register
(
this
.
_webComm
.
onDidReceiveMessage
(
e
=>
{
this
.
_onDidReceiveMessage
.
fire
(
e
);
}));
}
get
viewColumn
():
vscode
.
ViewColumn
|
undefined
{
return
this
.
_viewColumn
;
}
set
viewColumn
(
_value
)
{
throw
readonly
(
'
viewColumn
'
);
}
get
kernel
()
{
return
this
.
_kernel
;
}
set
kernel
(
_kernel
:
vscode
.
NotebookKernel
|
undefined
)
{
throw
readonly
(
'
kernel
'
);
dispose
()
{
this
.
_onDidDispose
.
fire
();
this
.
_onDidDispose
.
dispose
();
}
get
editor
():
vscode
.
NotebookEditor
{
if
(
!
this
.
_editor
)
{
const
that
=
this
;
this
.
_editor
=
{
get
document
()
{
return
that
.
notebookData
.
notebookDocument
;
},
get
selection
()
{
return
that
.
selection
;
},
get
visibleRanges
()
{
return
that
.
_visibleRanges
;
},
revealRange
(
range
,
revealType
)
{
that
.
_proxy
.
$tryRevealRange
(
that
.
id
,
extHostConverter
.
NotebookCellRange
.
from
(
range
),
revealType
??
extHostTypes
.
NotebookEditorRevealType
.
Default
);
},
get
viewColumn
()
{
return
that
.
_viewColumn
;
},
get
onDidDispose
()
{
return
that
.
onDidDispose
;
},
edit
(
callback
)
{
const
edit
=
new
NotebookEditorCellEditBuilder
(
this
.
document
.
version
);
callback
(
edit
);
return
that
.
_applyEdit
(
edit
.
finalize
());
},
get
kernel
()
{
return
that
.
_kernel
;
},
setDecorations
(
decorationType
,
range
)
{
return
that
.
setDecorations
(
decorationType
,
range
);
}
};
}
return
this
.
_editor
;
}
_acceptKernel
(
kernel
?:
vscode
.
NotebookKernel
)
{
...
...
@@ -149,14 +169,6 @@ export class ExtHostNotebookEditor extends Disposable implements vscode.Notebook
this
.
_visible
=
value
;
}
get
visibleRanges
()
{
return
this
.
_visibleRanges
;
}
set
visibleRanges
(
_range
)
{
throw
readonly
(
'
visibleRanges
'
);
}
_acceptVisibleRanges
(
value
:
extHostTypes
.
NotebookCellRange
[]):
void
{
this
.
_visibleRanges
=
value
;
}
...
...
@@ -173,16 +185,6 @@ export class ExtHostNotebookEditor extends Disposable implements vscode.Notebook
this
.
_active
=
value
;
}
get
document
():
vscode
.
NotebookDocument
{
return
this
.
notebookData
.
notebookDocument
;
}
edit
(
callback
:
(
editBuilder
:
NotebookEditorCellEditBuilder
)
=>
void
):
Thenable
<
boolean
>
{
const
edit
=
new
NotebookEditorCellEditBuilder
(
this
.
document
.
version
);
callback
(
edit
);
return
this
.
_applyEdit
(
edit
.
finalize
());
}
private
_applyEdit
(
editData
:
INotebookEditData
):
Promise
<
boolean
>
{
// return when there is nothing to do
...
...
@@ -216,7 +218,7 @@ export class ExtHostNotebookEditor extends Disposable implements vscode.Notebook
compressedEditsIndex
++
;
}
return
this
.
_proxy
.
$tryApplyEdits
(
this
.
_viewType
,
this
.
document
.
uri
,
editData
.
documentVersionId
,
compressedEdits
);
return
this
.
_proxy
.
$tryApplyEdits
(
this
.
_viewType
,
this
.
notebookData
.
uri
,
editData
.
documentVersionId
,
compressedEdits
);
}
setDecorations
(
decorationType
:
vscode
.
NotebookEditorDecorationType
,
range
:
vscode
.
NotebookCellRange
):
void
{
...
...
@@ -237,21 +239,4 @@ export class ExtHostNotebookEditor extends Disposable implements vscode.Notebook
decorationType
.
key
);
}
revealRange
(
range
:
vscode
.
NotebookCellRange
,
revealType
?:
extHostTypes
.
NotebookEditorRevealType
)
{
this
.
_proxy
.
$tryRevealRange
(
this
.
id
,
extHostConverter
.
NotebookCellRange
.
from
(
range
),
revealType
??
extHostTypes
.
NotebookEditorRevealType
.
Default
);
}
async
postMessage
(
message
:
any
):
Promise
<
boolean
>
{
return
this
.
_webComm
.
postMessage
(
message
);
}
asWebviewUri
(
localResource
:
vscode
.
Uri
):
vscode
.
Uri
{
return
this
.
_webComm
.
asWebviewUri
(
localResource
);
}
dispose
()
{
this
.
_onDidDispose
.
fire
();
super
.
dispose
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录